how to find peaks

조회 수: 21 (최근 30일)
David
David 2023년 11월 2일
답변: Dyuman Joshi 2023년 11월 2일
I want to find peaks from a plot, but I won't to use "findpeaks".
my professor told me to create a treshold in certain point and then count the peak as a region with "imfill".
I still didn't know ho to execute that, can someone give me some advice.
Here is an example code:
x=linspace(1,10);
y=sin(2*x);
plot(x,y)

채택된 답변

Dyuman Joshi
Dyuman Joshi 2023년 11월 2일
I don't see how imfill would work with curves and plots (unless saved as an image, of course).
findpeaks finds the local maxima.
So, a simple workaround is to use islocalmax paired with logical indexing -
x=linspace(1,10);
y=sin(2*x);
idx = islocalmax(y);
plot(x,y)
hold on
plot(x(idx), y(idx), '*', 'MarkerSize', 10)
legend({'function', 'peaks'})
ylim([-1.2 1.2])

추가 답변 (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