how to find peaks

20 ビュー (過去 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 Center および File ExchangeDescriptive Statistics についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by