blob: abc816f29ed171682fd3d1c870a35a061ab6a8bc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
//example 3.14
//lagrange's interpolation formula
//page 105
clc;clear;close;
y=[4 12 19];
x=[1 3 4];
y_x=7;
Y_X=0;
poly(0,'y');
for i=1:3
p=x(i);
for j=1:3
if i~=j then
p=p*((y_x-y(j) )/( y(i)-y(j)))
end
end
Y_X=Y_X+p;
end
disp(Y_X,'Y_X=');
|