I am trying to linearly fit a set of data points, find the slope and then compute the uncertainty of the slope, +, - uncertainty. How can I do this in MATLAB?
I have tried to look into regression and regress but are getting very confused.
What is the outputs of Regress? Does it gives the slope of the linear fit? And the 95% confidence intervals? I noticed that b not the same as the polyfit?
Likewise, the polyfit does not give the same slope as regression. And Regression gives me matrix of result.. shouldn't slope just be one value. The inputs are just vectors of x,y data.
Do you also want to fit an offset? Polyfit does that for you, but you have to tell regress explicitly,. Example:
x = 1:10 ; y = 10*x+3 ; yr = y + rand(size(y))-0.5 ; % add noise [b, bint] = regress(yr(:), [x(:) ones(numel(x),1)])