Removing large parts of an array
15 views (last 30 days)
Show older comments
I have an array that has around 8000 elements. I wish to delete the last 7000 in a simple way, so that I am left with an array that has just the first 1000. Is there any way to do this?
Accepted Answer
Voss
on 20 Feb 2022
If it is a row or column vector:
x = randn(1,8000);
size(x)
last_n_to_remove = 7000;
x(end-last_n_to_remove+1:end) = [];
size(x)
More Answers (0)
See Also
Categories
Find more on Matrices and Arrays in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!