How can i reduce the size of an array?
57 views (last 30 days)
Show older comments
hey everyone, i have an array with a lot of elements and i just will examine some of them. How can i reduce the array to have an array with only the elements, that i will examine? for example, if i have an array with 0:200 elements and will remove the elements 0:49 and 151:200, to get the new array with just 100 elements (from 50 to 150), how could i proceed?
Best regards.
0 Comments
Accepted Answer
Adam
on 11 Apr 2015
Edited: Adam
on 11 Apr 2015
a = 0:200;
then either
a(1:50) = [];
a(152:201) = [];
or
a( [1:50 152:201] ) = []
or simply:
a = a(51:151);
Matlab arrays are indexed from 1 though so I don't know if you meant 0:200 as indices or actual values in the array, but either way the method is the same.
0 Comments
More Answers (1)
See Also
Categories
Find more on Matrix Indexing 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!