x1=[3 4 2 2 4 4 5 3 6 5]
x2=[2 1 2 3 5 4 8 6 7 4]
A=[x1(:) ones(size(x1(:)))];
b=x2(:);
xx1=A\b; %same as xx=inv(A'*A)*A'*b;   A'*A*xx=A'*b
y1=A*xx1
A=[x2(:) ones(size(x1(:)))];
b=x1(:);
xx2=A\b;% same as inv(A'*A)*A'*b; A'*A*xx=A'*b
y2=A*xx2
plot(x1,x2,'x',x1,y1,'b',y2,x2,'r','linewidth',3);axis equal;
legend('Actual data','x1 based LMS fitting','x2 based LMS fitting');
