how mark the highest maximums of a graph?
Show older comments
hello, I try to mark the highest maximums of a graph that I make using data from an excel. but I can't.
the code i use is this:
% Representación Gráfica
plot(t_al,m_al)
xlabel("tiempo"), ylabel("nivel")
datetick('x',10)
grid on
%findpeaks(select,Fs,'MinPeakDistance',0.005)
I get an error with the select function and I don't know what to do
Accepted Answer
More Answers (1)
Bjorn Gustavsson
on 10 Mar 2022
You might get something from a simple solution like this (if your curve is not too noisy):
[m_al_max,idx_max] = max(m_al);
hold on
plot(t_al(idx_max),m_al_max,'rx')
HTH
4 Comments
Victoria Pilar Quesada García
on 10 Mar 2022
Bjorn Gustavsson
on 10 Mar 2022
That is another can of worms entirely - then you're back to the more general solutions provided by the different versions of findpeaks - since you most likely want peaks, but not noisy local maxima. You could possibly get something with:
m_al_threshold = 3.14;
idxM = find((diff(m_al(1:end-1))>0) & ...
(diff(m_al(2:end))<0) & ...
m_al(2:end-1)>m_al_threshold) + 1;
plot(t_al(idxM),m_al(idxM),'co')
But this version gladly picks out all noise-peaks and ignore peaks where m_al have a couple of consecutive identical values. (a proper QD-solution - might get the job done, might make your hands dirty.)
Victoria Pilar Quesada García
on 10 Mar 2022
Bjorn Gustavsson
on 10 Mar 2022
You're welcome.
Categories
Find more on Annotations 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!