Advanced Notes on Data Fitting for Physical Science

These notes outline data fitting in the physical sciences using MATLAB’s versatile and powerful ‘fit’ function which utilizes a least-squares algorithm. The emphasis is on how to use the fit function and interpreting the fit results; explanations on the theory of statistics are kept to a minimum. (Sources on MATLAB and Statistics are listed at the end.)

The entire fitting procedure is presented as a MATLAB Live Script which can be modified to be used for any data as long the input is in the form of column vectors x, y, sig_y. A PDF and HTML version of the Live Script has also been provided below.

For more information, see also: Basic Notes on Data Plotting and Fitting in MATLAB for Physical Science

MATLAB Live Script (Download): FittingWriteup2018.mlx

PDF File (View): FittingWriteup2018.pdf

PDF File (Download): FittingWriteup2018.pdf

HTML File (Download): FittingWriteup2018.html

MATLAB Linear Fitting App

We have integrated the above files into a convenient MATLAB app which allows fitting data to a first order y = p1*x + p2 and second order polynomial, y = p1*x^2 + p2*x + p3. The app displays the fitted results, the goodness of fit and provides plots and histogram of the weighted residues, the weighted residues squared as well as the fit's Chi Squared distribution and its error surfaces. Existing MATLAB variables can be used for the fit or sample data can be generated in the app. A link and a screen shot is shown below.

Download MXP LSQFit MATLAB app.

PDF File Images