Keyboard operated peak fitting function for time-series signals.


Updated 23 Dec 2018

View License

An interactive peak fitting program for time-series signals, written as a self-contained 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. See http://www.wam.umd.edu/~toh/spectrum/InteractivePeakFitter.htm for more information. Version 13.2, December 2018: D key saves model to disc as SavedModel.mat, containing two matrices: DataSegment and ModelMatrix. To place model in the workspace, type load SavedModel; to plot saved DataSegment, type plot(DataSegment(:,1), DataSegment(:,2)); to plot SavedModel, type plot(ModelX,ModelMatrix); each component in the model will be plotted in a different color.

Cite As

Tom O'Haver (2023). ipf(arg1,arg2,arg3,arg4) (https://www.mathworks.com/matlabcentral/fileexchange/23452-ipf-arg1-arg2-arg3-arg4), MATLAB Central File Exchange. Retrieved .

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

Inspired: peakfit.m

Community Treasure Hunt

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

Start Hunting!
Version Published Release Notes

Version 13.2, December 2018. Modified "d" key to save the model to disc as SavedModel.mat.

Version 13, November, 2017: 24 peak shapes selectable by single-keypress; 49 peak shapes selectable from menu (press "-")
Version 13, November, 2017. 24 peak shapes selectable by single-keypress; 49 peak shapes selectable from menu (press "-")

October, 2015. Version 113 adds lognormal model(o); minimum peak width constraint (Shift-W); saturation maximum (shift-M) to ignore points above saturation maximum.

Version 11 adds polynomial fits (Shift-o, for pOlyminial), bug fixes, adds Shift-Ctrl-S and Shift-Ctrl-P keys to transfer the current signal to iSignal and iPeak.

Version 10.4, June, 2014. Moves fitting result text to bottom panel of graph. Log mode (M key) toggles log mode on/off, fits log(model) to log(y). Replaces bifurcated Lorentzian with Breit-Wigner-Fano resonance peak (Shift-B key; Shape=15).

Version 10.3 adds a "down step" sigmoid (Shift-D; shape #23).

Version 10.2 fixes some bugs in the X key and C key functions in the bipolar (+ and -) mode.

Version 10 adds support for multiple-shape models.

Version 9.84 has some bug fixes related to starting values.

Version 9.8 adds Shift-C to specify custom first guess ('start' vector).

Version 9.7 adds Voigt profile shape; corrects for flat baseline if autozero mode 3.

Version 9.5 adds two new peak shapes: exponentially broadened Lorentzian and the alpha function.

Version 9.2: bug fixes; Reorganized peak shape table ('-' key)

Version 9.1 Adds fixed-position Gaussians (shape 16) and fixed-position Lorentzians (shape 17). Adds peak shape selection menu (activated by '-' key)

Version 9: Accepts additional input arguments to set the initial pan and zoom to focus on the data segment 'window' points wide, centered at x=center.

Version 8.94: Improved accuracy of autozero calculation.

Version 8.92: Added elapsed time to Q and R reports; Bug fixes; Slight improvement in speed of exponentially broadened shapes.

Added Gaussian/Lorentzian blend, bifurcated Gaussian, and bifurcated Lorentzian. Shift-X to enter value of 'Extra' for variable shapes; Shift-A and Shift-Z fine-tune the 'extra' variable. Bug fixes.

Version 8.8 has no limit in the number of peaks in the model.

Version 8.61 adds a simple built-in IQR function for those without the Statistics Toolbox.

Version 8.6 adds Fixed-width Gaussian (Shift-G key; shape number 11) and Fixed-width Lorentzian (Shift-L key; shape number 12)

Version 8.5, June 2012, Exponential
broadening uses normal rather than circular convolution.

Enhancements to the bootstrap statistics function.

Version 8, April 2012, Added bootstrap
sampling estimation of standard deviations of peak parameters ('v' key).

Version 7.1, Jan. 2012, Bug fixes in
background subtraction modes and in handlng very small data sets.

Version 7, Oct. 2011, adds linear/log
mode (M key) and exponential pulse and sigmoid models (U and S keys)

Version 6: T key (autozero) cycles through none, linear, and quadratic background subtraction. Minor bug fixes.

Version 5.9 adds user-selected number of points in background subtraction.

Add exponentially-broadened equal width Gaussians peak shape (J key)

Version 5.5 adds equal-width Gaussian and
Lortentzians and an 8-point baseline subtraction option.

Version 5.4, August, 2011: improved flexibility for data input arguments.

Bug fixes in Print peakfit function (W) and exponentially-broadened Gaussian.

Version 5.1 July 20, 2011: reformatted peak table on figure window, bug fixes

bug fix

Version 5.0 adds: graph of fitted peaks on the full signal display; Y command to display the entire signal full screen without cursors; various UI improvements and bug fixes.

Some minor big fixes and display improvements.

Expanded description

Improved performance on newer versions of Matlab; tested on 7.8 (R2009a).

Version 4.1, April 18: Added Autozero ON/OFF notification at top, and "k" keypress to print out list of commands.

Version 4: April 2008: Added keypress function "x" to refine the fit by performing 10 trial fits with slightly different first guesses and take the one with the lowest fitting error.

Version 3.5 computes the model at 100 points regardless of number of data points; adds keypress functions "t" to toggle between normal and autozero mode, and "d" to print out x,y values of the current data segment.