MATLAB: How to do OlS to get the residual

MATLABolsregressionresidual

The model is y=a+bt (t was the time,I changed it into id,y means the GDP per captital of US,a means the intercept) Here it is better that y could be transferred into log formal I am aimed at getting the minimum of the (y-yhat)^2. Further more ,I need to write code about it. But I have no idea where and how I can start it Could you tell me the code and logicality. Many thanks.

Best Answer