>> help measurepeaks
Peak detection and height and area measurement, similar syntax as
findpeaksSG with the addition of a 7th input argument that controls
plotting (0=no plots, 1=plots). The 3rd to 6th input arguments can be
scalars or vectors with one entry for each segment.
M=measurepeaks(x,y,SlopeThreshold,AmpThreshold,SmoothWidth,FitWidth,plots)
Locates and measures the positive peaks in a noisy x-y time series data.
Detects peaks by looking for downward zero-crossings in the first
derivative whose upward slopes exceed SlopeThreshold. Returns matrix (M)
containing peak number, the absolute peak height, peak-valley difference,
perpendicular drop area, and the tangent skim area of each peak.
Arguments "SlopeThreshold", "AmpThreshold" and "SmoothWidth" control peak
sensitivity of each segment. Higher values will neglect smaller features.
"SmoothWidth" is a vector of the widths of the smooths applied before
peak detection; larger values ignore narrow peaks. If smoothwidth=0, no
smoothing is performed. "FitWidth" is a vector of the number of points
around the top part of the peak that are taken for initial estimate of
the peak center and width (minimum 3). If plots = 0, the function does
not plot; if plots=1, the function plots the signal and numbers the peaks
in figure 1 and plots each peak separately and marks the valley positions
in an array of subplots in figure 2). Note: this function uses
SmoothWidth only for peak detection; it performs measurements on the raw
unsmoothed y data. If the data are noisy, it may be beneficial to smooth
the y data yourself before calling measurepeaks.m, using any smooth
function of your choice.
See http://terpconnect.umd.edu/~toh/spectrum/Smoothing.html and
http://terpconnect.umd.edu/~toh/spectrum/PeakFindingandMeasurement.htm
(c) T.C. O'Haver, 2016. Version 1.1, December, 2016
Example 1: sin(x).^2 has theoretical peaks at x=0.5pi, 1.5pi, 2.5pi,
3.5pi..., with peak heights of 1.0 and peak areas of pi/2 = 1.5708.
disp(' Peak Position PeakMax Peak-valley Perp drop Tan skim')
x=[0:.01:20]';y=sin(x).^2;measurepeaks(x,y,0,0,5,5,1)
Example 2: The built-in "humps" function has two peaks, no noise.
measurepeaks(0:.01:2,humps(0:.01:2),0,0,1,1,1)
Example 3: Series of peaks that get progressively taller and wider.
x=[0:.01:5]';y=x.*sin(x.^2).^2;measurepeaks(x,y,0,0,5,5,1)
Example 4: Like example 3, with random white noise added.
x=[0:.01:5]';y=.1.*randn(size(x))+x.*sin(-x.^2).^2;
measurepeaks(x,y,.001,.5,15,15,1)
Example 5; Like example 3, with added rising baseline.
x=[0:.01:5]';y=x+x.*sin(x.^2).^2;measurepeaks(x,y,0,0,5,5,1)
Example 6: Gaussian on linear baseline, theoretical area = 1.7725
x=[0:.1:10];y=2+x/10+exp(-(x-5).^2)+.01.*randn(size(x));
disp(' Peak Position PeakMax Peak-valley Perp drop Tan skim')
disp(measurepeaks(x,y,0.0001,0.3,3,5,1))
Peak-valley and Tan skim are most accurate height and area measures.
Example 7: Two overlapping Gaussians, zero baseline, theoretical area = 1.7725
x=[0:.05:10];y=exp(-(x-6).^2)+exp(-(x-3.5).^2)+.01.*randn(size(x));
disp(' Peak Position PeakMax Peak-valley Perp drop Tan skim')
disp(measurepeaks(x,y,0.0001,0.5,8,6,1))
PeakMax and Perp drop are most accurate height and area measures.
Example 8: Narrow Gaussian peak on sloping linear baseline, followed by
much broader peak, theoretical heights 1 and 1, areas 1.59 and 31.9.
x=1:.2:150;
y=(150-x)./200+gaussian(x,30,1.5)+gaussian(x,90,30);
measurepeaks(x,y,[0.001 .00005],[.6 .6],[5 120],[8 150],1)
Example 6: Noisy Gaussian on linear baseline, theoretical area = 1.7725
>> x=[0:.1:10];y=2+x/10+exp(-(x-5).^2)+.01.*randn(size(x));
>> disp(' Peak Position PeakMax Peak-valley Perp drop Tan skim')
>> disp(measurepeaks(x,y,0.0001,0.3,3,5,1))
Example 7: Two overlapping noisy Gaussians, theoretical area = 1.7725
>> x=[0:.1:10];y=exp(-(x-6).^2)+exp(-(x-4).^2)+.01.*randn(size(x));
>> disp(' Peak Position PeakMax Peak-valley Perp drop Tan skim')
>> disp(measurepeaks(x,y,0.0001,0.5,8,6,1))