Main Content

Determine Peak Widths

Create a signal that consists of a sum of Gaussian curves. Specify the location, height, and width of each curve.

x = linspace(0,1,1000);

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

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

Measure the widths of the peaks using half prominence and half height as reference.

tiledlayout("flow")
nexttile
findpeaks(y,x,Annotate="extents")
title("Half-Prominence Peak Widths")
nexttile
findpeaks(y,x,Annotate="extents",WidthReference="halfheight")
title("Half-Height Peak Widths")

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.

Select the tallest peaks separated by at least 0.5 units in the x-axis. Measure the widths of the peaks using half prominence and half height as reference.

figure
tiledlayout("flow")
nexttile
findpeaks(y,x,MinPeakDistance=0.5,Annotate="extents")
title("Half-Prominence Peak Widths")
nexttile
findpeaks(y,x,MinPeakDistance=0.5,Annotate="extents", ...
    WidthReference="halfheight")
title("Half-Height Peak Widths")

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.

Only the first and last peaks satisfy the minimum separation condition, so the widths displayed in the plot correspond to these two peaks. The extent of each peak remains unchanged, so the peak width preserves its value regardless of the conditions specified and whether the peak is selected or not.