How to find number of times graph goes back to zero

조회 수: 3 (최근 30일)
Sharah
Sharah 2014년 6월 15일
댓글: Star Strider 2014년 6월 16일
Hello everyone, I am new to MATLAB and I am currently plotting a normalised gyroscope data as in the picture below, and I am trying to count the number of the graph trying to go back to zero (on the word, number of the graph descending after reaching each peak)
For example, if I calculate it manually fromthe graph, it's around 9 times it tries to go back to zero. But I am trying to do analysis on big data so I really ned way of finding it by MATLAB.
Help me, thanks

채택된 답변

Star Strider
Star Strider 2014년 6월 15일
To find the troughs, invert the ‘y’ values and use findpeaks:
Example:
x = linspace(0,250,250); % Create Data
y = 0.25*sin(0.25*pi*x) .* exp(-(x-125).^2./1000) + exp(-(x-125).^2./1000);
[pks,plocs] = findpeaks(y); % Find peaks
[trs,tlocs] = findpeaks(0.1+max(y) - y); % Find troughs
figure(1)
plot(x, y)
hold on
plot(x(plocs), y(plocs), '^r', 'MarkerFaceColor','r') % Plot peaks
plot(x(tlocs), y(tlocs), 'vg', 'MarkerFaceColor','g') % Plot troughs
hold off
grid
produces:
  댓글 수: 6
Sharah
Sharah 2014년 6월 16일
thank you, that solution is very helpful. yes, i do have another problem with it but i posted on anther question http://www.mathworks.co.uk/matlabcentral/answers/134657-how-to-detect-point-before-it-went-on-plateau
Star Strider
Star Strider 2014년 6월 16일
My pleasure!
I saw your other post and suggested a solution.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Descriptive Statistics에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by