Info

This question is closed. Reopen it to edit or answer.

Find array elements in another vector

1 view (last 30 days)
Chi-Yu Lee
Chi-Yu Lee on 12 May 2015
Closed: MATLAB Answer Bot on 20 Aug 2021
Hi, everyone
I am stuck by MATLAB right now. I really appreciate if I could have your suggestion on this.
I have a vector "delta" where I would like to retract its value for further calculation.
This would be based on another vector showing a stage of "delta vector" as "NR" or others and if the continued epoch number of NR is bigger than 30 (if there are more than 30 epoch in NR present continually).
Then I want to find values of first three epochs and last three epochs in this continued NR in order to calculate the changes in the values.
So far my script looks like this, which I can know the sequence number of first epoch in each continued NR (2,j) and numbers of each continued NR (1,j).
i = 1;
j = 1;
delta = VarName5+VarName6+VarName7+VarName8;
continued_epoch_number = zeros(2,1);
for i=1:4320
switch Stage{i}
case 'NR'
if Stage{i}==Stage{i+1}
difference(i) = 1;
continued_epoch_number(1,j) = continued_epoch_number(1,j) + 1;
if continued_epoch_number(1,j) == 1
continued_epoch_number(2,j) = i;
end
else
difference(i) = 0; % if the next stage is other else
j = j + 1; % jump to next element
continued_epoch_number(1,j) = 0;
continued_epoch_number(2,j) = 0;
end
end
end
But I do not know how to move on to find those epoch and their values in "delta"
Perhaps, my description is not clear enough. I will do my best to explain my situation so please feel free to ask me about this code.
Best Regards

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!