peakfit.m Version history: Version 3.7 and later works in Octave as well as in Matlab. Version 4.0 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. Version 4.2 corrects some bugs and adds a Voigt profile peak shape. Version 4.3 adds 12th input argument, for + or +/- peak mode. Version 5.0 adds the ability to fit multiple peak shapes in one signal. See Examples 24, 25, and 28 below. Version 5.1 includes "baseline" as an additional output argument (for the flat baseline correction mode 3). Version 5.3 separates sigmoid peak shape into 'up sigmoid' or logistic function (shape 10) and 'down sigmoid' (shape 23). Version 5.4: June, 2014. Replaces bifurcated Lorentzian with Breit-Wigner-Fano resonance peak (Shape=15). 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, as shown in the figure on the right. 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. Version 5.8: September, 2014 adds optional 14th input argument DELTA (controls the variance in start values between successive trials when NumTrials>1). The default value is 1.0; larger values give more variance. Version 6: October, 2014 adds slope linear (Shape 26), useful for fitting baselines; polynomial (shape 28), and articulated segmented linear (shape 29). Version 6.01 The third output argument, baseline, returns the polynomial coefficients of the baseline in linear and quadratic baseline modes (1 and 2) or the value of the constant baseline in flat baseline mode. Version 6.1: January, 2015. Returns and displays both the mean fit error and the R-squared (Coefficient of determination) value. Version 6.2: February, 2015, adds two additional optional input arguments: minimum peak width constraint ("minwidth"); and saturation maximum ("clipheight") to ignore points above saturation maximum. Version 7: March 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). See Examples 25-28 below. Version 7.4: August 2015. 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) Version 7.45: September 2015. Reports FWHM for Voigt shapes (shape numbers 20 and 30). Version 7.5: November, 2015, Allows different width for each peak in fixed-widths shapes (11, 12). Enter the widths as a vector, one element for each peak. Version 7.6: November, 2015, New fixed-width shapes 34-37 added: 34=fixed-width Voigt; 35=fixed-width Gaussian/Lorentzian blend; 36=fixed-width exponentionally-broadened Gaussian; 37=fixed-width Pearson. See example 30 in help file. (old) Version 7.7: December, 2015, Data are centered and scaled for better numerical performance of the fitting algorithm, especially noticeable if the data window you are fitting is very small (0.1% or less) compared to its mean x value. Withdrawn January 2016 because of bugs. Version 7.7: March, 2016. Added shapes 38=variable time constant ExpLorentzian; and 40=sine wave. Also, "extra" defaults to 1 if not specified in the input arguments. Version 7.9: April, 2016, Added shapes 38=variable time constant ExpLorentzian; 40=sine wave; 41=rectangle; 42=flattened Gaussian; 43=Gompertz function (3 variables); "extra" defaults to 1 if not specified in input arguments. Version 8, July 2016. Adds shape 46 (quadslope), for fitting curved baselines. See example 33 in the built-in help. Version 8.2: August 2016, adds shape 48 equal-width exponential pulse. Version 8.4 May 2017. Adds shape 39, variable exponentially broadened Gaussian, alternative to shape 31. Same shape but parameterized differently. Shape 31 reports the width as the FWHM of the original Gaussian and shape 39 reports the standard deviation (sigma) of that Gaussian. Shape 31 reports the width as the exponential in the number of data points and shape 39 reports the reciprocal of time constant in tine units. See the script GaussVsExpGauss.m, Figure windows 2 and 3. Version 8.5: October, 2017, Changed IQR report in the bootstrap method to IQR/1.34896, which equals the RSD without outliers for a normal distribution. Version 9, January 2018. Adds peak shape 50 ("multilinear regression"), used when the peak positions and widths are known, and only the peak heights are unknown. The peak shapes, positions, and widths are specified in the 10th input argument "fixedparameters", which must in this case be a matrix listing the peak shape number (column 1), position (column 2), and width (column 3) of each peak, one row per peak. See the demonstration scripts peakfit9demo.m and peakfit9demoL.m. Version 9.2: June 2018, Modified Voigt peak shapes to report separate Gaussian and Lorentzian widths as the 4th and 6th columns of FitResults.