This MATLAB function creates a scatter plot and computes the linear regression providing slope and intercept, determination coefficient and root mean squared error (RMSE).
scatter_fit(x,y);
scatter_fit(x,y,'limits',[4 16]);
scatter_fit(x,y,'limits',[4 16],'reference',1);
scatter_fit(x,y,'limits',[4 16],'reference',1,'color',y);