%% Create Custom Nonlinear Models and Specify Problem Parameters and Independent Variables
% Construct fit types for custom nonlinear models, designating problem-dependent parameters and independent variables.
% Construct a fit type for a custom nonlinear model, designating n as a problem-dependent parameter and u as the independent variable.

g = fittype('a*u+b*exp(n*u)',...
            'problem','n',...
            'independent','u')

%
% Construct a fit type for a custom nonlinear model, designating time as the independent variable.

g = fittype('a*time^2+b*time+c','independent','time','dependent','height')

%
% Construct a fit type for a logarithmic fit to some data, use the fit type to create a fit, and plot the fit.

x = linspace(1,100);  
y = 5 + 7*log(x);
myfittype = fittype('a + b*log(x)',...
    'dependent',{'y'},'independent',{'x'},...
    'coefficients',{'a','b'})
myfit = fit(x',y',myfittype)
plot(myfit,x,y)

% You can specify any MATLAB command and therefore any .m file.
% Copyright 2015 The MathWorks, Inc.