say I have vector A, and I have some parts of this vector that I've identified to be true in a certain condition. For example, Lets say I want to find parts of the vector A that are bigger than 5, and I want it to be at least 4 consequetive samples after each other to be above 5. In the below example, let's say that i've found this between index 20 and 30, and 60 and 70. So lets say
A = rand(1,100)
crossThreshold = A > 5;
conditionArray = find(diff(crossThreshold));
conditionArray = [20 30; 60 70];
If I want to have the values in A corresponding with these parts, I'd generally say Id use the colon operator, like
Is there a nifty way to do this directly from the arrayy conditionArray? Intuitively I'd look for something like
A([conditionArray(:,1) : conditionArray(:,,,2)])
But this only give me the indices for the elements in the first row of conditionArray (in this case it gives 20:30)
I guess you could loop this, but I keep thinking there is a clever way to do this. Anyone have an idea?
0 Comments
Sign in to comment.