Finding position of main peak and difference between main peak and next peak in a 1d plot
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Vinay Killamsetty
le 28 Mai 2021
Commenté : Star Strider
le 30 Mai 2021
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.
0 commentaires
Réponse acceptée
Star Strider
le 28 Mai 2021
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)
[maxpk,idx] = max(y)
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'})
.
2 commentaires
Plus de réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!