MATLAB: How to find coefficients of a polynomial , Given values of the function

interpolationMATLABpolynomial

Given and f(1) = 2.3 , f(2) = 4.8, f(3) = 8.9, f(4) = 16.9 , f(5) = 41
how to find .
b = [2.3;4.8;8.9;16.9;41.0]
x = [1 2 3 4 5]
A = fliplr(vander(x))
coef = A\b
This is my attempt I'm not sure about it.

Best Answer

t = [1; 2; 3; 4; 5];
y = [2.3; 4.8; 8.9; 16.9; 41.0]
M=[ones(5,1), t, t.^2, -y.*t, -y.*t.^2];
x=M\y;
c0=x(1); c1=x(2); c2=x(3); d1=x(4); d2=x(5);
% Check
f=@(t) (c0+c1*t+c2*t.^2)./(1+d1*t+d2*t.^2)
f(t)
Related Question