-
How to remove all elements greater than 5 from a vector.
myVector = [10 0 0 1 12 3 0 0 4 5 1 12 0 0];
%index contains indices of elements within myVector which are greater than 5
index = find(myVector > 5);
myVector(index) = []Alternatively, logical indexing can be used (and is more efficient)
myVector(myVector > 5) = [];
This is one of the "tricks" or methods to manipulate the arrays using Matlab.
- wong chee tat :)
No comments:
Post a Comment