Home

Awesome

BiErfFit

BiErfFit provides a tool to fit a hysteresis curve simultaneously with two linear combinations of error functions. For brevity, we call the curve which forms the left part of the hysteresis, curve α, and that which forms the right part, curve β. The model used to fit each curve is given by:

f(x) ~ Baseline + errorfunc1(x) + errorfunc2(x) + ... + errorfuncN(x)

where each error function is a derived form of the standard erf function as given by:

errorfunc(x) ~ (Height/2) (1 + erf( 2 sqrt(ln(2))(x - Center)/Width))

Baseline, Center, Width, and Height are the fit coefficients.

Important Notes

Licensing

This software is licensed under the GNU General Public License (version 3).

Tested On

Requirements

Setting Up

  1. Download or git-clone this repository and other repositories listed in the Requirements.
  2. Add the repositories to the MATLAB's search path via addpath(genpath( ... )) OR this version control system.

Usage

Construct the BiErfFit object in the following ways, and the fit results will be populated in the object's public properties.

obj = BiErfFit(Data, ... Name-Value ...)

OR

obj = BiErfFit(XData, YData, ... Name-Value ...)

OR

% Create an empty BiErfFit object.
obj = BiErfFit();

% Specify the data points and curve-fit settings via property assignments.
obj.XData = ... ;
obj.YData = ... ;
obj.Property1Name = Value1;
obj.Property2Name = Value2;
...

% Perform the curve fitting by reinstantiating the BiErfFit object.
obj = BiErfFit(obj);

Data must be specified as a cell containing two elements: the first for curve α and the second for curve β. Each element must be a two-column (or two-row) matrix where the first column (or first row) is the X data points and the second column (or second row) is the Y data points. In the alternative syntax, XData and YData are respectively the X and the Y data points, also specified as a two-element cell; but instead of matrix, the elements must be a vector.

The curve-fit settings can be specified after the mandatory arguments in Name-Value syntax, e.g. BiErfFit(Data, 'Window', [10,90], 'NumErfs', [2,3]). If no settings are specified, the algorithm will attempt to fit the hysteresis curve using the default settings. The default option fits curve α and curve β with one error function each, and may not produce a good fit.

Name-Value Pair Arguments

Any of the public properties can be specified as arguments in Name-Value syntax during the object construction. Specifying other things as Name-Value arguments will return an error.

Examples

The fitting algorithm works sufficiently well if the start points of the fitting are specified as done in the following example. Finding the right start points involves some guess work and trial and error. The accuracy of the fit can be improved by specifying the lower and upper bounds of the fitting. The figure shown below is the reflectivity switching of VO2:Er (Lim2014). The left curve was fitted with two error functions, and the right, with one error function, by using the command:

Fit=BiErfFit(Data, ...
    'BaselineStart', ... ,...
    'CenterStart', { ... , [ ... , ... ]}, ...
    'HeightStart', { ... , [ ... , ... ]}, ...
    'WidthStart', { ... , [ ... , ... ]});

The full code is given in Examples/VO2Er_transition.m. Two-element vectors are supplied to the start points for the right curve because there are two error functions to be fitted.

<img title="VO2:Er transition" src="/Examples/VO2Er_transition.png" width="480px">

Public Properties

Fit Results

Fitting Start Points

Fitting Lower Bounds

Fitting Upper Bounds

Algorithm Parameters

Public Methods

Static Methods