I need to interpolate a function using polynomial interpolation, but I'm not sure how to code the part to get the polynomial and its coefficients:
My function:
fx = @(x) sin(3 .*x) ./ (0.4 .+ (x .-2) .^2);
My 9 sample values:
xs = 0:0.5:4;
ys = fx(xs);
My attempt:
n = 2;
x(1) = xs; # not sure if this is correct
for k=1:n-1
for j=k+1:n
p = ((x(1) - x(j)) / x(1) - x(j))* fx(x(j));
endfor
endfor
But I feel really lost and I don't quite understand. Could someone help me out?