how to change the markers and line style, for 'findpeaks' ?

14 ビュー (過去 30 日間)
Fercho_Sala
Fercho_Sala 2021 年 5 月 5 日
コメント済み: Walter Roberson 2021 年 10 月 7 日
Hello, According to the next code, how can I change the ‘markers’ and line style using the ‘findpeaks’ function? Thank you.
[pks,locs,widths,proms] = findpeaks(pws(:,end),y,'MinPeakHeight',trd);
findpeaks(pws(:,end),y,'Annotate','extents','WidthReference','halfprom');
text(locs+0.5,pks,num2str((1:numel(pks))'));
legend('Filtered Data','Peak','Prominence','Width','FontSize',5);

採用された回答

Walter Roberson
Walter Roberson 2021 年 5 月 5 日
編集済み: Walter Roberson 2021 年 10 月 7 日
ax = gca;
sig_h = findobj(ax, 'tag', 'Signal');
peak_h = findobj(ax, 'tag', 'Peak');
As you are asking to plot Extents as well, you will also have entries with tag 'Height', 'HalfHeightWidth', 'Border' (multiple); or 'Prominence', 'HalfProminenceWidth', 'Border' (multiple)
You can then set the LineStyle and Marker properties according to your preferences.
  9 件のコメント
AStro
AStro 2021 年 10 月 7 日
For some reason the Prominence and HalfProminenceWidth tag is not recognized in my code
[pks_wc,locs_wc,widths,proms] = findpeaks(ampl_bgcorr,freq,'MinPeakDistance',p,'MinPeakProminence',10,'Annotate','extents','WidthReference','halfheight');
figure(1)
findpeaks(ampl_bgcorr,freq,'MinPeakDistance',p,'MinPeakProminence',10,'Annotate','extents','WidthReference','halfheight')
ax = gca;
sig_h = findobj(ax, 'tag', 'Signal');
peak_h = findobj(ax, 'tag', 'Peak');
proms_h = findobj(ax, 'tag', 'Prominence');
halfProm_h = findobj(ax, 'tag', 'HalfProminenceWidth');
peak_h.Marker = '.';
peak_h.MarkerSize = 10;
peak_h.Color = 'r';
sig_h.Color = 'b';
proms_h.Color = 'r';
halfProm_h.Color = 'r';
Change of the style of sig_h and peak_h are executed properly but for proms_h I get error message:
Property assignment is not allowed when the object is empty. Use subscripted assignment to create an array element.
Error in CWT_software_v4 (line 142)
proms_h.Color = 'r';
Walter Roberson
Walter Roberson 2021 年 10 月 7 日
I think I will need your data to test with

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

その他の回答 (1 件)

Image Analyst
Image Analyst 2021 年 5 月 5 日
I always plot the results myself:
[peakValues, indexesOfPeaks] = findpeaks(................)
plot(x, y, 'b-', 'LineWidth', 2); % Plot original data.
hold on;
% Extract peak locations from x and y.
xp = x(indexesOfPeaks);
yp = y(indexesOfPeaks);
plot(xp, yp, 'rv', 'LineWidth', 2, 'MarkerSize', 10); % Plot triangles atop the peaks.
Or you could skip creating xp and yp and have for the last line
plot(x(indexesOfPeaks), peakValues, 'rv', 'LineWidth', 2, 'MarkerSize', 10); % Plot triangles atop the peaks.

カテゴリ

Help Center および File ExchangeDescriptive Statistics についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by