MATLAB: Define a period indices to find a specific value of a vector.

define indicesfindperiodic cycle

Dear Collegue,
In my code, I have a variable (vector) "y", and I have to specify some conditions for the desirable values to change it. I can do it perfectly for the 1st cycle. However, as the time increase, I could not find the reaming values.
The using command is "find" as following:
y(find(y>=0 & t>=0.0141 & t<=0.0423),no)= HR+HJous;
y(find(y<0 & t>0.0705 & t<0.0987) ,no)= HR-HJous;
Note: the periodic time is 0.1128 seconds. Also; I try expand the find command, to include finding the 1st numbers of peak, however since the time variable "t" it does not increase (or change), the result were, also, just pick the peaks in 1st cycle.
Thanks

Best Answer

Dear All,
I found the answer to my question from my dear friend Mahdi.
This is the solution by using floor function
y(y >= 0 & (t/Tp-floor(t/Tp))>= (0.0141 & (t/Tp-floor(t/Tp)) <=0.0423= 5; where Tp is the time period: 0.1128 s.
Special thanks for my question contributors.
and thanks again, Mahdi.