L=[1 2; 2 1; 4 1]Define the known RHS data vector by typing
t= [3 ; 3 ; 5]
s = inv(L'*L)*L'*t
e = (L*s-t)'*(L*s-t)Are the equations consistent or inconsistent? Why?
t= [3 ; 2 ; 8]Are the equations consistent or inconsistent?
s=inv(L'*L)*L'*t; x=[-5:5];for i=1:3;plot(x,(t(i)-L(i,1)*x)/L(i,2));hold on;end xlabel('x');ylabel('y');plot(s(1),s(2),'*');hold off;axis([-5 5 -5 5]);Is the least squares solution (labeled as * in MATLAB graph) consistent with the expected "best" solution to all 3 equations?
W=[1/22 0 0;0 1 0; 0 0 1] ;L=W*L;t=W*t; s=inv(L'*L)*L'*t; x=[-5:5];for i=1:3;plot(x,(t(i)-L(i,1)*x)/L(i,2));hold on;end xlabel('x');ylabel('y');plot(s(1),s(2),'*'); hold off;axis([-5 5 -5 5]);