polynomial help, is it to simply just use polyfit? I cant figure it out, I don't use matlab regularly
4 views (last 30 days)
Show older comments

2 Comments
John D'Errico
on 9 Apr 2022
Please stop posting your homwework problems with no effort made. Answers is not a service where we do your homework for you.
Accepted Answer
Image Analyst
on 8 Apr 2022
Hint
Put this in a loop where you increase the order
coefficients = polyfit(x, y, order);
estimatedy = polyval(coefficients, x);
plot(x, y, 'r.', 'MarkerSize', 10);
mse(order) = sum((estimatedy - y).^2)
figure;
plot(mse, 'b-', 'LineWidth', 2)
grid on;
2 Comments
Image Analyst
on 9 Apr 2022
Yeah, pretty close. I'd just make a few changes but that would be just to make the plots prettier.
More Answers (1)
Matt J
on 8 Apr 2022
Yes, you could do most of it with polyfit.
4 Comments
Sam Chak
on 8 Apr 2022
I think the assignment requires you to fit the data points with polynomials from the 1st-degree to the 10th-degree, if I'm not mistaken.
p01 = polyfit(x, y, 1);
p02 = polyfit(x, y, 2);
p03 = polyfit(x, y, 3);
p04 = polyfit(x, y, 4);
p05 = polyfit(x, y, 5);
p06 = polyfit(x, y, 6);
p07 = polyfit(x, y, 7);
p08 = polyfit(x, y, 8);
p09 = polyfit(x, y, 9);
p10 = polyfit(x, y, 10);
See Also
Categories
Find more on Tables in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!