During my exercise, I'd like to draw a regression line fitted with the following quadratic equation.
The followings are the code I wrote down.
y = log(wage(index));
x = [ones(length(y), 1) experience(index) experience(index).^2];
b = (x'*x)^(-1)*x'*y;
yhat = x*b;
plot(x(:, 2), y, '.', x(:, 2), yhat);
And this is the result.
I firstly guess the single curve will be shown on the figure, but... why is there a bunch of lines, and how can I fix this with minimization of fixing?
Thank you in advance, guys.