3rd degree polynomial interpolation in functions

11 ビュー (過去 30 日間)
Utku Palakci
Utku Palakci 2018 年 12 月 30 日
コメント済み: Utku Palakci 2018 年 12 月 30 日
How can I find "y" at "x=28" with 3rd degree?
x y
0 0
10 0.2
15 0.5
20 0.9
22.5 1.2
25 1.6
30 2.2
35 3.1
40 4.1
45 5.2
50 6.5
75 13.9
100 24.9
150 58.3
200 97.6

採用された回答

Michael Madelaire
Michael Madelaire 2018 年 12 月 30 日
Please do not send your data in like that. I have to copy it in some how and now it is just ugly...
% Define x
x = [0
10
15
20
22.5
25
30
35
40
45
50
75
100
150
200];
% Define y
y = [0
0.2
0.5
0.9
1.2
1.6
2.2
3.1
4.1
5.2
6.5
13.9
24.9
58.3
97.6
];
% Make fit
degree = 3;
fit = polyfit(x,y,degree);
x_fit = 0:0.01:200;
y_fit = polyval(fit, x_fit);
% Illustrate fit
figure;
plot(x,y);
hold on;
plot(x_fit, y_fit);
grid on;
xlabel('x');
ylabel('y');
legend('Data', 'Polyfit', 'Location', 'best');
title(sprintf('at x = 28 y is %.2f',polyval(fit,28)))
  1 件のコメント
Utku Palakci
Utku Palakci 2018 年 12 月 30 日
My apologies and thank you so much.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangePolynomials についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by