3rd degree polynomial interpolation in functions

조회 수: 9 (최근 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)))

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Polynomials에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by