Question: Ps7.mat contain scores for 100 subjects on two different tests. Use the linear regression function you wrote in class to fit a linear model to these data. Plot the data using a scatter plot and plot the fitted model with a line. Report the estimated parameters a and b in the figure title. Then, use polyfit to find the best-fit line predicting score2 from score1. Your coefficients should be the same as the ones you found using your linear regression function in problem 2. List these coefficients in a comment or show them on the figure.
Below I have included my regression line, my a (named alpha) and b (named beta) parameters (that I hope are correct), and what I plugged in for polyfit. I am a bit concerned because my polyfit gives me 0 -0.1606 , and my b is also equal to -0.1606 so I want to make sure that is correct, and if not where I'm going wrong.
function [b,a,rsq] = regressline(x,y)
sigxsq= sum(x.^2) - (sum(x)^2)/n;
plot(x,(beta*x) + alpha, 'r')