31 views (last 30 days)

Show older comments

I am using the curvit toolbox of Matlab and I was wondering how can I get the standard error for each of the fitted parameters:a, b, c, and z. Let's say the x and y data points are:

x = [10, 20, 30, 40]

y = [0.1, 0.02, 0.01, 0.001]

you can visuzlize the data points by the code below

plot(x,y,'*')

The x, y data should fit to function below

function [fitresult, gof] = createFit(x, y)

[xData, yData] = prepareCurveData( x, y );

% Set up fittype and options.

ft = fittype( 'a*exp(b/(x-c)^z)', 'independent', 'x', 'dependent', 'y' );

opts = fitoptions( 'Method', 'NonlinearLeastSquares' );

opts.Display = 'Off';

opts.Lower = [0 0 0 0];

opts.StartPoint = [0.001 0.952083907850712 0.7812 2];

opts.Upper = [1 Inf Inf 3];

% Fit model to data.

[fitresult, gof] = fit( xData, yData, ft, opts );

% Plot fit with data.

figure( 'Name', 'untitled fit 1' );

h = plot( fitresult, xData, yData );

legend( h, 'y vs. x', 'untitled fit 1', 'Location', 'NorthEast', 'Interpreter', 'none' );

% Label axes

xlabel( 'x', 'Interpreter', 'none' );

ylabel( 'y', 'Interpreter', 'none' );

grid on

end

Jeff Miller
on 13 Feb 2021

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!