MATLAB: How to calculate the uncertainty of the coefficient produced by polyfit

MATLAB

How would I calculate the uncertainty of individual “P” coefficients in,
 
>> [P,S] = polyfit(x,y,n)

Best Answer

This can be easily done using the "fit" and "confint" functions from the Curve Fitting Toolbox instead of "polyfit". The workflow might look like:
 
>> fitType = fittype('a*x^2 + b*x + c') % The equation for your fit goes here
>> f = fit(x,y,fitType);
>> uncertainty = confint(f,0.90) % Calculated 90% confidence intervals for each coeff of the fit.