Find specific peaks and their positions
16 次查看(过去 30 天)
显示 更早的评论
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 个评论
Star Strider
2019-12-27
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.
采纳的回答
Cris LaPierre
2019-12-28
编辑:Cris LaPierre
2019-12-28
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')
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!