here is my equation : y=a+bx;
x=[1 2 3 4 5 6];
y=[3.5 0.5 -1.5 -3 -4.5 -7 ];
I've try this code
clc;
clear all;
close all;
X=[1; 2; 3; 4; 5; 6];
Y=[3.5; 0.5; -1.5; -3; -4.5; -7];
N=length(X);
AB=(X'.*X)*(X'.*Y);
plot(X,Y,'o')
hold;
plot(AB(1:3,:),AB(4:6,:),'r-');
is that right? and what is the values of a,b