Linear fit (What is the standard error)

5 views (last 30 days)
Chan
Chan on 9 Sep 2015
Edited: Chan on 9 Sep 2015
Hi, all,
I make a linear fit for my data.
% linear fit
P = polyfit(x,y,1);
yfit = P(1)*x+P(2);
I can find the zero by taking the division of -P(2)/P(1). My question is, what is the standard error for the -P(2)/P(1) I find? What is the matlab code for this?
  1 Comment
Chan
Chan on 9 Sep 2015
Edited: Chan on 9 Sep 2015
I have found the solution. It's rather straightforward.
[P,S,mu] = polyfit(y,x,1); % has to flip the position of x and y
[y_center,error] = polyval(P,0,S,mu);

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!