Find specific peaks and their positions
16 views (last 30 days)
Show older comments
Richard Rees
on 27 Dec 2019
Commented: Richard Rees
on 31 Dec 2019
Good afternoon,
I have an ongoing problem where I want to find the specific peaks and localities within a data set automatically. The test data shows 4 typical data plots that can be found in a simulation that I am running. What I need jpeg shows 9 locations in total, the problem I have is that I cannot capture these points across all the data sets because the peak count is different owing to different areas of the simulation they were taken.
My method has been to find the peak locations, plot these as these changes (2nd figure) represent the change in water level, then find the gradient and where these changes occur from positve to negative. However, this has not worked because some of the trends continue to be negative. So, I tried interpolating, "ischange" with variance, mean etc and including filtering, smoothing, islocal max, findpeakpts and I still cannot capture what I need.
Is there a way to do this?
2 Comments
Star Strider
on 27 Dec 2019
The signals in ‘test_data.mat’ are sinusiods. They do not look anything like the plot you posted.
We need to see the code — and data — you used to get those plots.
Accepted Answer
Cris LaPierre
on 28 Dec 2019
Edited: Cris LaPierre
on 28 Dec 2019
This is quick and dirty, but it finds 8 of the 9 peaks you specified (technically #9 is not a peak, so I leave it to you to determine how to handle it).
Basically, I compute the abs difference of the signal you indicated. This creates peaks at each step change. I can then use findpeaks to identify the location of these peaks. I used the MinPeakProminence name-value pair to help select just the desired peaks.
Here's the code (first 2 lines) plus a visualization to check the results.
stpData = abs(diff(ppks{4}));
[pks,loc]=findpeaks(stpData,"MinPeakProminence",0.25);
figure
plot(ppks{4})
hold on
plot(stpData)
plot(loc,ppks{4}(loc),'ro')
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!