Fitting sigmoid to data

lollercoaster picture lollercoaster · May 12, 2013 · Viewed 22.8k times · Source

There are many curve fitting and interpolation tools like polyfit (or even this nice logfit toolbox I found here), but I can't seem to find anything that will fit a sigmoid function to my x-y data.

Does such a tool exist or do I need to make my own?

Answer

Eitan T picture Eitan T · May 12, 2013

If you have the Statistics Toolbox installed, you can use nonlinear regression with nlinfit:

sigfunc = @(A, x)(A(1) ./ (A(2) + exp(-x)));
A0 = ones(size(A)); %// Initial values fed into the iterative algorithm
A_fit = nlinfit(x, y, sigfunc, A0);

Here sigfunc is just an example for a sigmoid function, and A is the vector of the fitting coefficients.