second largest peak value
조회 수: 42 (최근 30일)
이전 댓글 표시
I'm getting the amp of second largest peak as correct but the time is wrong ?
How to obtain the second highest value X,Y from this and plot as already Y is correct ,X seems to be in wrong region?
s=load ('30827.mat');
signal(1,1:length(s.ans))=s.ans;
load t.mat;
[PkAmp, PkTime] = findpeaks(abs(hilbert(signal(1,:))),t);
[highestPeak, indexOfHighestPeak] = max(PkAmp);
[a(1),b2]=max(abs(hilbert(signal(1,:))));
[a2(1),b6]=max(PkAmp(PkAmp<max(PkAmp))); % to get second largest peak value
% error is the time value calcluate and plotted wrong??
Highesttime(1,:) = t(b2);
Highest2time(1,:) = t(b6);
figure;
plot(t,(signal(1,:)),t,abs(hilbert(signal(1,:))),t(b2),a(1),'ro')
hold on
plot(PkTime, PkAmp, '^r', 'MarkerFaceColor','r')
xlim([0 0.0006]);ylim([-inf inf])
grid on
hold on,plot(t(b6),a2(1),'ko')
hold off
댓글 수: 0
채택된 답변
Alex Mcaulley
2019년 6월 12일
To obtain the coordinates of the second peak you just need:
[PkAmp, PkTime] = findpeaks(abs(hilbert(signal(1,:))),t);
[~,idx] = sort(PkAmp,'descend');
PkAmp(idx(2)) %Amplitude of the second peak
PkTime(idx(2)) %Time of the second peak
추가 답변 (1개)
참고 항목
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!