主要内容

确定峰宽

R2026b

创建一个由几条高斯曲线之和组成的信号。指定每条曲线的位置、高度和宽度。

x = linspace(0,1,1000);

Pos = [1 1.5 3 5 7 8]'/10;
Hgt = [7 6.2 3 2 2 3]';
Wdt = [3 2.5 4 3 4 6]'/100;

y = sum(Hgt.*(exp(-((x-Pos)./Wdt).^2)),1);

使用相对高差的一半处和半高处作为参考来测量峰宽。

tiledlayout("flow")
ax11 = nexttile;
findpeaks(y,x,Annotate="extents")
title("Half-Prominence Peak Widths")
ax12 = nexttile;
findpeaks(y,x,Annotate="extents",WidthReference="halfheight")
title("Half-Height Peak Widths")
ylim([ax11 ax12],[0 9])

Figure contains 2 axes objects. Axes object 1 with title Half-Prominence Peak Widths contains 4 objects of type line. One or more of the lines displays its values using only markers These objects represent signal, peak, prominence, width (half-prominence). Axes object 2 with title Half-Height Peak Widths contains 6 objects of type line. One or more of the lines displays its values using only markers These objects represent signal, peak, height, width (half-height), border.

将 MinPeakDistance 设置为 0.5,以选择在 x 轴上相隔至少 0.5 个单位的最高波峰。使用相对高差的一半处和半高处作为参考来测量峰宽。只有第一个和最后一个峰满足最小间距条件,因此图中显示的宽度对应于这两个峰。

请注意,无论指定条件如何,或是否由于这些条件的序列而选择某个峰,每个峰都保留其宽度。

figure
tiledlayout("flow")
ax21 = nexttile;
findpeaks(y,x,Annotate="extents",MinPeakDistance=0.5)
title("Half-Prominence Peak Widths")
ax22 = nexttile;
findpeaks(y,x,Annotate="extents",MinPeakDistance=0.5, ...
    WidthReference="halfheight")
title("Half-Height Peak Widths")
ylim([ax21 ax22],[0 9])

Figure contains 2 axes objects. Axes object 1 with title Half-Prominence Peak Widths contains 4 objects of type line. One or more of the lines displays its values using only markers These objects represent signal, peak, prominence, width (half-prominence). Axes object 2 with title Half-Height Peak Widths contains 6 objects of type line. One or more of the lines displays its values using only markers These objects represent signal, peak, height, width (half-height), border.