FUNCTION REFERENCE

lsqcurvefit

Fit the parameters of a model to data in the least-squares sense.

Fit the parameters of a model to data in the least-squares sense.

Syntax

x = lsqcurvefit(fun, x0, xdata, ydata)

Syntax

x = lsqcurvefit(fun, x0, xdata, ydata, lb, ub)

Syntax

x = lsqcurvefit(fun, x0, xdata, ydata, lb, ub, options)

Syntax

[x, resnorm, residual, exitflag, output] = lsqcurvefit(...)

Minimises sum((fun(x, xdata) - ydata).^2) with the method, options and exit

flags of lsqnonlin. residual is fun(x, xdata) - ydata.

Example

t = (0:5)'; x = lsqcurvefit(@(p, t) p(1)*exp(p(2)*t), [1 0], t, 2*exp(-0.5*t))   % [2 -0.5]

Differences from MATLAB: as for lsqnonlin.

These are the engine’s help pages. Each page keeps its compatibility notes. File operations are unavailable in the browser.