Finding position of main peak and difference between main peak and next peak in a 1d plot

조회 수: 2 (최근 30일)
How to find the position of main peak in a 1 d plot
Then how to find the value of the difference between the main peak and the next peak in the same plot.

채택된 답변

Star Strider
Star Strider 2021년 5월 28일
x = linspace(0,10);
y = 1.5*exp(-(x-2).^2) + 2*exp(-(x-7).^2*2.5) + exp(-(x-9).^2*5);
[pks,locs] = findpeaks(y)
pks = 1×3
1.4994 1.9954 0.9996
locs = 1×3
21 70 90
[maxpk,idx] = max(y)
maxpk = 1.9954
idx = 70
figure
plot(x, y)
hold on
plot(x(locs), pks, '^r')
hold off
Result = table(pks(:),locs(:),(locs(:)-idx),(x(locs(:))-x(idx)).', 'VariableNames',{'Peaks','Indices','Index_Difference','X_Difference'})
Result = 3×4 table
Peaks Indices Index_Difference X_Difference _______ _______ ________________ ____________ 1.4994 21 -49 -4.9495 1.9954 70 0 0 0.99959 90 20 2.0202
.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Descriptive Statistics에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by