Measure time difference peaks and stores it
Mostrar comentarios más antiguos
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

Respuesta aceptada
Más respuestas (2)
David Hill
el 17 de Ag. de 2022
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
mpz
el 18 de Ag. de 2022
0 votos
1 comentario
Star Strider
el 18 de Ag. de 2022
As always, my pleasure!
Categorías
Más información sobre Descriptive Statistics en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


