I have a rather simplistic example that I would like to learn the best possible solution for. I have a data set:
depth = [0:0.5:20];
I want to only select ‘depth’ from a specific range, for example from 2 to 5. I can do this by:
d1 = find(depth == 2,1,'first');
d2 = find(depth == 5,1,'first');
depth = depth(d1:d2);
Is there an alternative, cleaner way of doing this?
just use logical indexing: