function Multi_linear_regression_example1
x1 = [.2 .5 .6 .8 1.0 1.1]'; %Make it a column vector using transpose
x2 = [.1 .3 .4 .9 1.1 1.4]';
y = [.17 .26 .28 .23 .27 .24]';
%y is a column vector. X is a 6x3 matrix
%X=[1 0.2 0.1; 1 0.5 0.3; 1 0.6 0.4;...]
%a is a column vector. a=[a0 a1 a2]'
%Y=X*a comes from correlation y=a0+a1*x1+a2*x2. We have 3 unknowns (a0
%a1, a2), but there are 6 equations. This means regression!
X = [ones(size(x1)) x1 x2] %size gives array dimension
a = X\y
%The operator \ in Matlab specifically solves y=X*a. If there are more
%equations (= number of data points), regression is performed.
%check max error
Y = X*a
MaxError_in_y = max(abs(Y - y))