Calculate peak of pulses above certain threshold

21 views (last 30 days)
Can you please guide how can I find the first peak of each pulse and its location. I use the peak command but peak time consider oscillations aslo. As seen in figure that each pulse decays in certain time. I just want to take in account the first rise of each pulse above any threshold value during a time duration 't'
  2 Comments
MANINDER CHOUDHARY
MANINDER CHOUDHARY on 11 May 2022
Please find the attached data. If you plot data you will see number of pulses, I just want to consider peak value of each pulses throgout the cycle. If you zoom out the signal each signal (except noise) rise and then decacys. I want to consider the rise of signal only and time at which it rises.

Sign in to comment.

Accepted Answer

Mathieu NOE
Mathieu NOE on 11 May 2022
hello
@Chunru : why the envelop ? this can create enough signal distorsion so that the peak instant is misread. I understand that some signal filtering could help remove spurious peaks
even simpler code :
load example.mat
figure;
plot(C);
findpeaks(C,'MinPeakDistance',1000, "MinPeakHeight",0.005); % doc findpeaks for more options
  2 Comments
Chunru
Chunru on 11 May 2022
Hi @Mathieu NOE. The envelope helps to remove the fake peaks due to fluctuations. It is supposed to have more robust peak detection (with oscillation around the peaks). The following may demonstrate the difference.
t= 0:0.001:10
t = 1×10001
0 0.0010 0.0020 0.0030 0.0040 0.0050 0.0060 0.0070 0.0080 0.0090 0.0100 0.0110 0.0120 0.0130 0.0140 0.0150 0.0160 0.0170 0.0180 0.0190 0.0200 0.0210 0.0220 0.0230 0.0240 0.0250 0.0260 0.0270 0.0280 0.0290
x = (2+cos(2*pi*.5*t)).*cos(2*pi*200*t);
plot(t, x)
hold on;
[~, locs] = findpeaks(x,'MinPeakDistance',100);
plot(t(locs), x(locs), '^');
e = envelope(x, 100, 'peak');
[~, locs] = findpeaks(e,'MinPeakDistance',100)
locs = 1×6
3 2001 4001 6001 8001 9999
plot(t(locs), e(locs), 'go', 'MarkerFaceColor', 'g');
Mathieu NOE
Mathieu NOE on 11 May 2022
hello again
ok - yes I recognize it can help in some cases. But it's sometimes tricky to find a way to smooth / envelop a signal with very sharp peaks without some time distorsion / shift of the peak
I believe evry situation is special and you have to try different solutions . here we see envelop works fine because the signal is quite nice - not abrupt and noisy as in the post.

Sign in to comment.

More Answers (1)

Chunru
Chunru on 11 May 2022
load example.mat
%whos
plot(C(19e5:20e5));
% compute envelope before findpeaks
env = envelope(C, 1000, 'peak');
hold on
plot(env(19e5:20e5));
figure;
findpeaks(env); % doc findpeaks for more options
hold on;
plot(env)

Community Treasure Hunt

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

Start Hunting!