Measure time difference peaks and stores it
이전 댓글 표시
Hi,
Can anyone help me with a code to measure the time difference from the moment the peak is 1 till it goes back to zero and then stores it. Then it repeats again for the next peak and the next till it goes over all the peaks. So for example the graph below shows the first peak occurs at around 15197 seconds and ends at 15562 seconds, hence time difference is 365s which is then stored in a matrix. Then the code continues to the next peak and measures that time then stores it. It keeps doing that until it stores all those times.
find peak doesn't work well for my data to use widths and all that. I need some type of for and if loop. Any help appreciated

채택된 답변
추가 답변 (2개)
David Hill
2022년 8월 17일
I assume you have an t-array and a y-array.
c=1;
while any(y>=1)
f1=find(y>=1,1);
y(1:f1-1)=[];
f2=find(y<=0,1);
y(1:f2-1)=[];
deltaT(c)=t(f2)-t(f1);%provides an array of the peak time periods
t(1:f2-1)=[];
c=c+1;
end
카테고리
도움말 센터 및 File Exchange에서 Descriptive Statistics에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


