I have a vector a = [1 5 3 4 2]. I’d like to find all elements of a, which are 1<a<5. How do I do it in Matlab?
Personally I’ve developed one solution, but it’s cumbersome:
a = [1 5 3 4 2];
ix = find(a>1);
ix = ix(find(a(ix)<5));
disp(a(ix))
What’s a better way?
Use logical indexing: