how mark the highest maximums of a graph?

조회 수: 10 (최근 30일)
Victoria Pilar Quesada García
Victoria Pilar Quesada García 2022년 3월 10일
댓글: Bjorn Gustavsson 2022년 3월 10일
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

채택된 답변

Steven Lord
Steven Lord 2022년 3월 10일
Let's plot some sample data.
x = 0:360;
y = sind(x).*(x-60).*(x-180).*(x-210)/(360.^2);
plot(x, y)
hold on
Identify the local maxima and plot a second "line" highlighting them with circles.
L = islocalmax(y);
plot(x(L), y(L), 'o')
  댓글 수: 2
Victoria Pilar Quesada García
Victoria Pilar Quesada García 2022년 3월 10일
thanks, but what I need would be for the program to mark the maximums that are greater than a certain "y" or maximums that are at a distance 'x' between them.
would you know how to do the second?
Bjorn Gustavsson
Bjorn Gustavsson 2022년 3월 10일
You're latest request becomes a very messy task. For that I would definitely write a function. Because now you have to handle selection of maxima in a "not at all obvious manner" what about high peaks that are way above the threshold but a bit close in x, how to handle a slightly lower peak that is just outside the x-separation to the highest peak but within that x-separation to a sub-peak close to the highest one, should that third peak be included or excluded. This is too much hassle to just toss something together on a whim without rather careful and precise specifications.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Bjorn Gustavsson
Bjorn Gustavsson 2022년 3월 10일
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
Victoria Pilar Quesada García
Victoria Pilar Quesada García 2022년 3월 10일
thank you so much !!!
Bjorn Gustavsson
Bjorn Gustavsson 2022년 3월 10일
You're welcome.

댓글을 달려면 로그인하십시오.

카테고리

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

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by