%% Find Coefficient Order to Set Start Points and Bounds
% For the properties Upper, Lower, and StartPoint, you need to find the order of the entries for coefficients.
% Create a fit type.

ft = fittype('b*x^2+c*x+a');

%
% Get the coefficient names and order using the coeffnames function.

coeffnames(ft)

% Note that this is different from the order of the coefficients in the expression used to create ft with fittype.
%
% Load data, create a fit and set the start points.

load enso
fit(month,pressure,ft,'StartPoint',[1,3,5])

% This assigns initial values to the coefficients as follows: a = 1, b = 3, c = 5.
%
% Alternatively, you can get the fit options and set start points and lower bounds, then refit using the new options.

options = fitoptions(ft)
options.StartPoint = [10 1 3];
options.Lower = [0 -Inf 0];
fit(month,pressure,ft,options)

% Copyright 2015 The MathWorks, Inc.