How to find first two largest peaks with sample location

58 ビュー (過去 30 日間)
Muhammad Usman Gul
Muhammad Usman Gul 2020 年 2 月 6 日
コメント済み: Bhaskar R 2020 年 2 月 6 日
Please let me know, how to find its two highest peaks along with its samples information too.
P wave.JPG

採用された回答

Bhaskar R
Bhaskar R 2020 年 2 月 6 日
d = rand(100,1); % assumed data
[vals,loc] = maxk(d,2); % first two peaks(mnaximum values) sample values and locations
plot(d); hold on; % plot original samples
plot(loc,vals,'rv', 'MarkerFaceColor', 'r'); % plot peak values
  2 件のコメント
Muhammad Usman Gul
Muhammad Usman Gul 2020 年 2 月 6 日
Your answer is work well iff and only if we are going to find out first-two maximum values. But here I would like to find out the first two largest peaks instead of maximum values. i.e in given figure, first and second peaks at 496 & 916 respectively. However, in your given function '"maxk" it will return 2nd maximum value which is a part of the first peak.
Thanks for your cooperation and I hope you got my point.
Bhaskar R
Bhaskar R 2020 年 2 月 6 日
Yeah, I got you. Use findpeaks to get all peak values of the samples
d = rand(100,1); % assumed data
[vals,locs] = findpeaks(d);
[val,loc] = maxk(vals,2); % first two peaks(mnaximum values) sample values and locations
plot(d); hold on; % plot original samples
plot(locs(loc),val,'rv', 'MarkerFaceColor', 'r'); % plot peak values

サインインしてコメントする。

その他の回答 (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