X = [1 6; 1 -3; 1 8]; X y = [4; 8; 10]; y P = X*pinv(X'*X)*X'; P yhat = P*y; yhat e = (eye(3)-P)*y; e plot_col3(X,y,20);