Finding local maxima on a slightly noisy data

22 次查看(过去 30 天)
Hi,
I have my plot,as shown in "Trajectory.png" file.
My X-Axis data is just:
Xdata = [1:100];
My Y-Axis data is as follows:
0
0
2.09222708159463
6.44546159330348e-07
2.09222611499462
1.13686837721616e-13
1.19629985182991
0.307031063055145
0.889191608677226
1.13686837721616e-13
1.13686837721616e-13
0
1.13686837721616e-13
1.13686837721616e-13
0
1.13686837721616e-13
1.02297834274279
0.0388633487946145
1.06185167072739
1.13686837721616e-13
0.361256176978336
0.609935965840200
0.219116803722684
0.752088093054083
1.13686837721616e-13
0
1.13686837721615e-13
1.13686837721617e-13
1.13686837721616e-13
12.7332583247782
144.877119357353
2.09424951365800
0.947857561548907
1.15967343285703
5.85842059479906
7.90599054430073
1.03340833244700
1.74611749440277
1.25454771605403
0.405678614930056
3.32781000899039
0.540378086763468
1.98803176650120
1.37173336776097
2.03332435894425
4.19689864919353
2.11301835089563
7.88897972952186
46.5756563901977
3.01603701789582
1.78266388299620
0.608273922686689
0.879773039416162
0.900317534766668
0.807217040648508
0.326548725644831
0.207175108036568
0.495172539519853
0.520077384058685
0.173410667917717
0.0642667898143524
0.131548850902771
0.161997164449503
0.0413293955654355
0.490113271390482
1.08274572574879
0.838386694466136
7.10542735760100e-15
0.0980279964920274
1.49459508834199
1.19798004219773
0.394520279605238
7.10542735760100e-15
7.10542735760101e-15
7.10542735760100e-15
1.47973128457182
0.718756197167734
0.382866238818068
2.58339794004342
2.10894362431230
44.0407985149444
98.6536822408392
7.40103735780748
2.22280189553396
1.99971342894857
2.71371333131814
5.99983968601066
2.57127665277943
5.68150302624610
0.257865115144954
0.0303588377283994
1.26389973299037
1.16741322335018
1.41971109494362
1.91582002185642
2.52274280044650
4.35828014515571
0.146871341252485
2.06696816496338
2.06293020725324
I want to find my local maxima for this plot.
In the plot,we can see that, there is a lot of noise.Due to this noise,When I try to find local maxima,with this function,I get around 16 points, instead of 3.
I am using the following code for finding local maxima:
[Maxima,MaxIdx] = findpeaks(K);
Here,K is Y-Axis data.(N x 1 data)
I would be really glad,if someone can explain,the procedure to remove the noise,so that finally,when we call the function to find Maxima,it gives us 3 values(i.e. at xvalues 31,50 and 82) instead of 16 values.

回答(2 个)

Jim Riggs
Jim Riggs 2018-12-6
The peaks are very distinct. Why not just select a threshold value (say, 20) and only use peaks that are above the threshold?
  1 个评论
Math Enthusiast
Math Enthusiast 2018-12-6
@Jim: That seems sensible.I think,I will proceed like that.
Could you also answer this.I basically have a 2D Trajectory,consisting of different lines and arcs.I am trying to find out breakpoints (the points, where each a curve C1 transforms into curve C2).
For example,if we have four lines (something like rectangle),I am following this method:
1) Find the curvature radius for all the points and plot it.
2) Then,I get the graph,like the one,I have attached in my query.The peaks having value more than threshold are basically the breakpoints.
It seems to work in case of Lines,but not sure,if this is the right approach,when I have a trajectory comprising of lines and arcs.Could you please explain if I need to use some kind of filter to find the correct peaks in this case.I mean, inorder to find the breakpoints,where a line is getting changed to arc.
Thanks

请先登录,再进行评论。


Akira Agata
Akira Agata 2018-12-6
I think one possible way would be setting 'MinPeakProminence' option in findpeaks function, like:
findpeaks(yourData,'MinPeakProminence',30)
peaks.png
  4 个评论
Math Enthusiast
Math Enthusiast 2018-12-10
@ImageAnalyst: Well, if you look at his code,he is also using, a threshold of "30".
So,obviously, I would have to find my threshold value properly.
Akira Agata
Akira Agata 2018-12-11
>Image Analyst-san and Math Enthusiast-san,
Thank you for your comments!
Yes, I have explicitly set a threshold to "30" in my previous code. If you want to automatically find a threshold value, you need to define the peak(s) you want.
For example, if you define "the peak(s)" as a peak with a prominence of more than three scaled median absolute deviations (MAD) away from the median value, the code will be like this:
[~,~,th] = isoutlier(yourData);
findpeaks(yourData,'MinPeakProminence',th)
Since the threshold becomes ~4.8 in this definition, findpeaks finds 4 peaks, as shown below.
peaks2.png

请先登录,再进行评论。

Community Treasure Hunt

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

Start Hunting!

Translated by