Calculate peak of pulses above certain threshold
5 次查看(过去 30 天)
显示 更早的评论
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' ![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/993450/image.jpeg)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/993450/image.jpeg)
2 个评论
Mathieu NOE
2022-5-10
hello
there are quite a fair amount of answers to this topic on this forum
etc...
If you still think you need help , attach some data and your code
采纳的回答
Mathieu NOE
2022-5-11
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 :
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/994455/image.png)
load example.mat
figure;
plot(C);
findpeaks(C,'MinPeakDistance',1000, "MinPeakHeight",0.005); % doc findpeaks for more options
2 个评论
Chunru
2022-5-11
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
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)
plot(t(locs), e(locs), 'go', 'MarkerFaceColor', 'g');
Mathieu NOE
2022-5-11
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.
更多回答(1 个)
Chunru
2022-5-11
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)
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!