MATLAB Answers

0

Finding Linear regression equation

HAAAAH 님이 질문을 제출함. 11 Sep 2019
최근 활동 Bruno Luong 님이 답변함. 11 Sep 2019
I have table of data
x = [65 65 62 67 69 65 61 67]
y = [105 125 110 120 140 135 95 130]
How can i find the equation y = mx+b of linear regression. I have tried so far but dont know how to find m and b ?
x = [65 65 62 67 69 65 61 67]
y = [105 125 110 120 140 135 95 130]
plot (x,y, 'r*')
lsline
% determine how many samples do we have
N= length(x)
% Fit to f(x) = b + m*x
X = [ones [N,1] x]
b = mldivide(X,y)

  댓글 수: 0

로그인 to comment.

태그

답변 수: 2

Torsten 님의 답변 11 Sep 2019
Torsten 님이 편집함. 11 Sep 2019

x = [65 65 62 67 69 65 61 67];
y = [105 125 110 120 140 135 95 130];
X = [ones(numel(x),1),x.'];
p = X\(y.');
b = p(1)
m = p(2)

  댓글 수: 0

로그인 to comment.


Bruno Luong 님의 답변 11 Sep 2019

P=polyfit(x,y,1);
m=P(1),
b=P(2),
% linefit = polyval(P,x)

  댓글 수: 0

로그인 to comment.



Translated by