The Ezyfit toolbox for Matlab enables you to perform simple curve fitting of one-dimensional data using arbitrary (non linear) fitting functions.
This toolbox is covered by the BSD License.
Why using EzyFit?
There are three ways to perform curve fitting with Matlab: the first one is using the 'Basic Fitting Interface' of Matlab, the second one is using fminsearch with an external function, and the third one is to pay for the Curve Fitting Toolbox. However, for usual curve fitting of 1D data, you may find the first solution rather limited (only polynomial fits), the second one a little complicated, and the third one quite expensive...
The EzyFit Toolbox provides a free, simple and efficient way to perform quick curve fitting with arbitrary (nonlinear) fitting functions. In the command-line mode, you just have to type something like showfit('c+a/x^n') and EzyFit gives you the values for c, a and n and shows you the curve! In the interactive mode, a new menu is added to your figure window to easily fit your data with predefined or user-defined fits.
EzyFit needs Matlab 7.0 or higher. It has been tested under 7.0 to 8.6 (R2015b). The command-line functions (e.g. ezfit, showfit...) work equally well on all systems. However some graphical operations may not be fully stable, especially on non-Windows systems.
1. Download and unzip the EzyFit Toolbox in a directory somewhere in your system. For instance, in a Windows installation, the directory Documents/MATLAB/ezyfit may be a good location. Do NOT install the toolbox directly in the directory of the Matlab application (Program Files/Matlab directory in Windows). If you upgrade from an older version, first empty the previous directory.
2. Select 'Set Path' (available in the menu File in Matlab 7, or in the tab Home in Matlab 8). In the dialog box, click on 'Add Folder' (NOT 'with subfolders') and select the ezyfit directory. Click on 'Save' and 'Close'.
3. If you want to always have the Ezyfit menu in your figures, type efmenu install. This will create or update your 'startup.m' file in the main user directory of your Matlab installation.
Note: If you upgrade Matlab and you want to use your previous Ezyfit installation, you just have to follow the steps 2-3.
First step: curve fitting from the EzyFit menu
First plot some sample data by typing plotsample. In the EzyFit menu of the figure window (see figure below), select Show Fit and choose an appropriate fitting function to fit the sample data. You may use the ``Data Brushing'' tool (available since Matlab 7.6 only) to fit only part of your data.
Choose Undo Fit if you want to remove the fit.
If multiple curves are present in the figure, first select the one you want to fit, and then choose Show Fit.
Two additional items, Get Slope and Show Slope, allows you to make a quick linear fit "by eye" of your data. Drag a line through your points (use the menu Insert > Line), and Get Slope gives you the equation of the line (works in linear/logarithmic scales).
Second step: curve fitting from the command window
Although fitting your data from the EzyFit menu is fast and easy, using the command-line functions is much more powerful.
The key function of the toolbox is ezfit, which computes the coefficients that fit the data. The function showfit simply calls the function ezfit for the active curve and displays the result. Type undofit to remove the last fit.
This example fits some noisy data by a power law c * x^n and plots the result:
plotsample power % a power law showfit c*x^n
This example fits an histogram with a Gaussian, and displays the coefficients in the Array Editor:
plotsample hist % an histogram f = ezfit('gauss'); % fits with a Gaussian f % displays the fit structure showfit(f); % displays the fit editcoeff(f); % opens the Array Editor
Have a look to the Sample session for more examples.
EzyFit page on the Matlab Central.
This page is hosted by FAST