How can I find the peak values of a curve?
20 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Ashfaq Ahmed
il 31 Ago 2022
Commentato: Abderrahim. B
il 31 Ago 2022
Hi all!
So I have these curves which have several peaks. Can anyone please tell me how can I detect the peaks and put a value to those points? The attached picture is manually created -
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1112925/image.png)
Any feedback from you will be highly appreciated! Thank you!
0 Commenti
Risposta accettata
Abderrahim. B
il 31 Ago 2022
Hi!
Demo:
randData = randi(10, 10, 5) ;
for ii = 1: length(randData(1,:))
plot(randData(:,ii))
findpeaks(randData(:,ii), "Annotate","peaks")
hold on
end
Hope this helps
2 Commenti
Abderrahim. B
il 31 Ago 2022
You are welcome.
Try this:
randData = randi(10, 10, 3) ;
for ii = 1: length(randData(1,:))
% plot(randData(:,ii))
[pks,locs] = findpeaks(randData(:,ii), 'Annotate','peaks');
findpeaks(randData(:,ii))
text(locs-0.04,pks+0.4,split(num2str(pks')))
hold on
end
hold off
Più risposte (1)
Cris LaPierre
il 31 Ago 2022
If you are using a live script, I suggest using the Find Local Extrema task. You can see an introduction to this tool in this recent live stream. It will allow you to interactively find the right settings to identify your peaks. If you prefer to do it programmatically, look into the findpeaks function.
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!