Finding local maxima on a slightly noisy data
12 views (last 30 days)
Show older comments
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.
0 Comments
Answers (2)
Jim Riggs
on 6 Dec 2018
The peaks are very distinct. Why not just select a threshold value (say, 20) and only use peaks that are above the threshold?
Akira Agata
on 6 Dec 2018
I think one possible way would be setting 'MinPeakProminence' option in findpeaks function, like:
findpeaks(yourData,'MinPeakProminence',30)

4 Comments
Akira Agata
on 11 Dec 2018
>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.

See Also
Categories
Find more on Multirate and Multistage Filters in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!