peakfit.m

Command-line peak fitter for time-series signals. Version 9.0, January 2018
17.5K Downloads
Updated 18 Jan 2018

View License

Editor's Note: This file was selected as MATLAB Central Pick of the Week

peakfit(signal,center,window,NumPeaks,peakshape,extra,NumTrials,start,autozero,fixedparameters,plots,bipolar,minwidth,DELTA,clipheight)
A command-line peak fitting program for time-series signals, written as a self-contained Matlab function in a single m-file. Uses a non-linear optimization algorithm to decompose a complex, overlapping-peak signal into its component parts. The objective is to determine whether your signal can be represented as the sum of fundamental underlying peaks shapes. Accepts signals of any length, including those with non-integer and non-uniform x-values. Fits any number of peaks of 44 different shapes, including models with multiple shapes. This is a command line version, usable from a remote terminal. It is capable of making multiple trial fits with sightly different starting values and taking the one with the lowest mean fit error, and it can estimate the standard deviation of peak parameters from a single signal using the bootstrap method.

Cite As

Tom O'Haver (2024). peakfit.m (https://www.mathworks.com/matlabcentral/fileexchange/23611-peakfit-m), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2017b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

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

Start Hunting!
Version Published Release Notes
9.0.0.0

Adds peak shape 50: multilinear regression, used when the peak positions and widths are both known and only the peak heights are to be determined.

8.5.0.0

Version 8.5 adds two new peak shapes and changes IQR (Interquatrile range) reported in the bootstrap method to
IQR/1.34896, which equals the relative standard deviation without outliers for a normal distribution.
Updated summary

8.1.0.0

Minor bug fix

8.0.0.0

Version 8: July 2016, adds shape 46 (quadslope), for fitting curved baselines. See example 33 in the built-in help.

7.45.0.0

This version corrects the Voigt profile model so that it reports the FWHM of the peak.

7.9.0.0

Version 7.9: April, 2016, Added shapes 38=variable time constant ExpLorentzian; 40=sine wave; 41=rectangle;
42=flattened Gaussian; 43=Gompertz function (3 variable logistic); 44=1-exp(-k*x). "extra" defaults to 1 if not specified in input arguments.
Edited discription

7.4.0.0

August, 2015, Allows fixed width models (shapes 11 ands 12)
to have different fixed widths for each peak (specified by a vector);
also adds a fixed-height Gaussian model (shape 34) with heights specified
by a vector (input argument 10)

7.2.0.0

Version 7.2: June, 2015, fixes bug when the bootstrap is used with multiple shape models.

1.49.0.0

Version 7.1: March, 2015, adds peak shapes with three iterated variables: 30=voigt (variable alpha), 31=ExpGaussian (variable time constant), 32=Pearson (variable shape factor), 34=Gaussian/Lorentzian blend (variable percent). See Examples 25-28.

1.48.0.0

Version 7.1: April, 2015, adds peak shapes with three unconstrained iterated variables: 30=Voigt (variable alpha), 31=ExpGaussian (variable time constant), 32=Pearson (variable shape factor), 34=Gaussian/Lorentzian blend (variable percent).

1.47.0.0

Adds an additional optional input argument, new peak shapes, and new output arguments.

1.46.0.0

Adds an additional optional input argument, new peak shapes, and new output arguments.

1.45.0.0

Version 5.7: August, 2014. Adds minimum width constraint as 13th input argument (See example 19); Can be a vector for multiple peak shapes. The default if not specified is the independent variable (x) interval.

1.44.0.0

Version 5.5: July, 2014. Adds shape 21 (triangular) and 25 (Lognormal distribution). Moves peak table to lower panel and plots residuals as red dots.

1.43.0.0

Version 5.4: June, 2014. Replaces bifurcated Lorentzian with Breit-Wigner-Fano resonance peak (Shape=15).

1.42.0.0

Version 5: Feb, 2014. Adds multiple-shape models, designated by using a vector as the 5th input argument. See examples 17 and 18.

1.41.0.0

Version 4.31: Jan, 2014. Adds 12th input argument, for + or +/- peak mode.

1.40.0.0

Version 4.2 ,corrects some bugs, adds an additional autozero mode that subtracts a flat baseline without requiring that the signal return to the baseline at both ends of the signal segment, and adds a Voigt profile peak shape.

1.39.0.0

Version 3.9 adds exponentially broadened Lorentzian(peak shape 18); and alpha function (peak shape 19).

1.37.0.0

Version 3.6: February, 2013. Addition of fixed-position Gaussian shape (16) and fixed-position Lorentzian shape (17).

1.36.0.0

Version 3.51: January, 2013. Improved accuracy of linear autozero calculation. Improved calculation of default "start" guess when not specified in the input arguments.

1.33.0.0

Version 3.4.2; Slight improvement in speed of exponentially-broadened shapes. Works in Matlab or Octave 3.6.1

1.31.0.0

Version 3.4: October, 2012. Works in Matlab or Octave 3.6.1

1.30.0.0

Version 3.3: September, 2012. Added 11th input argument ('plots') to turn plotting OFF (plots=0) or on (plots=1); added Gaussian/Lorentzian blend, bifurcated (asymmetrical) Gaussian and Lorentzian.

1.29.0.0

Version 3.1: September, 2012. Unlimited Number of peaks. Bug fixes.

1.27.0.0

Version 3: September, 2012, adds the ability to estimate the uncertainty of peak parameters using the bootstrap sampling method.

1.26.0.0

Version 2.6: June, 2012. Added fixed-width Gaussian and Lorentzian peak shapes (shape numbers 11 and 12).

1.25.0.0

Version 2.5: June, 2012, Allows zeros as placeholders for unspecified input arguments.

1.24.0.0

Version 2.4: May, 2012, Exponential broadening uses normal rather than circular convolution.

1.23.0.0

Version 2.4: May, 2012, Exponential broadening uses normal rather than circular convolution.

1.21.0.0

Version 2.3: January, 2012. Bug fixes in background subtraction modes and
in handlng very small data sets.

1.20.0.0

Version 2.3: January, 2012. Bug fixes in background subtraction modes and
in handlng very small data sets.

1.19.0.0

Version 2.2: October, 2011. Adds exponential pulse and sigmoid models

1.17.0.0

Version 2.1: Sept, 2011. Accepts AUTOZERO 0 (none), 1 (linear), or 2 (quadratic).

1.16.0.0

Bug fix

1.15.0.0

Version 1.8: Aug, 2011. Takes AUTOZERO setting as 9th input argument; improved data input argument flexibility.

1.10.0.0

Several bug fixes. Reformatted peak table on graph.

1.9.0.0

Expanded the description

1.8.0.0

Added two new peakshapes: 6=Equal-width Gaussians, and 7=Equal-width Lorentzians.

1.5.0.0

Added ability to access the x-y data for the individual fitted peaks, via the optional output parameters xi and yi.

1.2.0.0

Expanded description

1.1.0.0

Bug fixes. No major features added.

1.0.0.0