Write a MATLAB script which will load an n x 2 matrix A of data and determine slope m and y intercept b of a line which minimizes the least square distance the data {A(I,1),A(I,2)} from I=1 to n and the points {A(I,1),mA(I,1)+b} from I=1 to n.
m=1;
b=1;
for i=1:10000
m=((-b*x(i))-(x(i)*y(i)))/(x(i)^2);
b=((-m*(x(i)^2))+(x(i)*y(i)))/(x(i));
end
A=[m,b];
rref (A)
I got an error message: Undefined function 'x' for input arguments of type 'double'.

답변 (1개)

Nalini Vishnoi
Nalini Vishnoi 2014년 10월 2일

0 개 추천

You are getting this error because variables x and y are not defined in your script. I think what you intended was something like the following:
x = A(:,1);
y = A(:,2);

카테고리

도움말 센터File Exchange에서 Logical에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

질문:

2014년 10월 2일

답변:

2014년 10월 2일

Community Treasure Hunt

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

Start Hunting!

Translated by