I'm having an issue when trying to plot a 3rd-order polynomial regression. The code I have is:
figure
scatter(xtr, ytr, 'filled','b')
xlabel('x')
ylabel('y')
coef = polyfit(xtr, ytr, 3);
pp = polyval(coef,xtr);
hold on
plot(xtr,pp,'r-')
I don't understand what is wrong with how I'm plotting the line. My code works fine for polynomials of order 1.
