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)
  2 Comments
John D'Errico
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.
Chad Parker
Chad Parker on 10 Apr 2022
I'm not asking for you or anyone to solve the problem, I am requesting help/guidance. Simply helping my by providing the hyperlink to the pages to help would suffice, why were the others able to be helpful and you are quick to reject. Don't worry I won't ask any more questions on this page. Appreciate "your" help.

Sign in to comment.

Accepted Answer

Image Analyst
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
Chad Parker
Chad Parker on 9 Apr 2022
like this?
for order = 1:10;
coefficients = polyfit(x, y, order);
estimatedy = polyval(coefficients, x);
plot(x, y, 'r.', 'MarkerSize', 10);
grid on;
mse(order) = sum((estimatedy - y).^2);
end
figure;
plot(mse, 'b-', 'LineWidth', 2)
grid on;

Sign in to comment.

More Answers (1)

Matt J
Matt J on 8 Apr 2022
Yes, you could do most of it with polyfit.
  4 Comments
Chad Parker
Chad Parker on 8 Apr 2022
I found that polyfit page, but am I missing something? Maybe I am overthinking it, would it be polyfit(x,y,10)? and that is all the questions is asking? and maybe to plot?
Sam Chak
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);

Sign in to comment.

Categories

Find more on Tables in Help Center and File Exchange

Products


Release

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!