How to identify both sides of a flat peak (flat part of a signal)?

20 ビュー (過去 30 日間)
Tomaszzz
Tomaszzz 2022 年 7 月 13 日
コメント済み: Star Strider 2022 年 7 月 15 日
Hi all,
I have the following signal (also attached).
I am trying to find the peaks circles red. The below code does identify all the peaks circled black but i do not understand why it ommits the other side of a flat signal? Can you help please?
load 'signal'
[peak_value,peak_location]= findpeaks(-force_y_r, 'MinPeakProminence',10, 'MinPeakDistance',100);
peak_value = -peak_value;
plot(force_y_r, 'LineWidth',1.5); hold on
plot(peak_location,peak_value,'ko')

採用された回答

Star Strider
Star Strider 2022 年 7 月 13 日
Use the islocalmin (introduced in R2017b) function instead of findpeaks
LD = load('signal.mat');
force_y_r = LD.force_y_r;
Lv1 = islocalmin(force_y_r, 'FlatSelection','first', 'MinSeparation',500, 'MinProminence',750);
Lv2 = islocalmin(force_y_r, 'FlatSelection','last', 'MinSeparation',500, 'MinProminence',750);
x = 1:numel(force_y_r);
figure
plot(x, force_y_r)
hold on
plot(x(Lv1), force_y_r(Lv1), '^r')
plot(x(Lv2), force_y_r(Lv2), '^g')
hold off
producing:
It may be necessary to change the name-value pair parameters for other data sets. Use the find function to get numeric indices from the logical vectors.
.
  6 件のコメント
Tomaszzz
Tomaszzz 2022 年 7 月 15 日
Many thanks @Star Strider , this works perfect!
Star Strider
Star Strider 2022 年 7 月 15 日
As always, my pleasure!

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

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