I am trying to extract parts of a signal that meet a certain condition (boolean true) and save them into individual vectors.
Lets say i have a testvector:
testvector = [0 0 1 0 0 0 1 1 1 1 1 1 1 1 0 0 0 1 0 0 1];
Iterating through the signal, if the index is true, I want to check if:
- i-3 positions are 0 (condition1)
- i+5 positions are 1 (condition2)
If both conditions are true, I would like to extract this part of the signal, like mentioned earlier.
Concerning my testvector, due to my conditions there is supposed to be exactly one part to be extracted:
Until now, I've tried the following without success:
values=;for i=4:numel(testvector)if testvector(i)==1buff1 = i-3;buff2 = i+5;for k=buff1:1:(i-1)values = [values, testvector(k)];if any(values)values(end) = ;breakelseif length(values)>3breakendendfor k=i:1:buff2values = [values, testvektor(k)];if any(values)breakelseif buff2 > numel(testvektor)breakelseif (length(values)>10)continueendendnew = [new, testvektor(i)]endend
So far, I have no idea how to automatically construct a new vector each time the conditions are met and a part of the signal is extracted.
Thank you in advance, every help is highly appreciated!