Several Typical Interpolation in Matlab Lagrange Interpolation Supposing:x 144 169 225 y 12 13 15 If x=175, while y=
Solution :Lagrange Interpolation in Matlab: function y=lagrange(x0,y0,x); n=length(x0);m=length(x); for i=1:m z=x(i); s=0
0; for k=1:n p=1
0; for j=1:n if j~=k p=p*(z-x0(j))/(x0(k)-x0(j)); end end s=p*y0(k)+s; end y(i)=s; end input :x0=[144 169 225] y0=[12 13 15] y=lagrange(x0,y0,175) obtain the answer:x0 = 144 169 225 y0 = 12 13 15 y = 13
2302 Spline Interpolation Supposing: x 1 4 9 16 x1 2 3 4 Resolve the cubic spline function s(x)Solution :Input x=[ 1 4 9 6] ;y=[ 1 4 9 6] ;x=[ 1 4 9 6] ;pp=spline(x,y) pp = form: 'pp' breaks: [1 4 6 9] coefs: [3x4 double] pieces: 3 order: 4 dim: 1 output : pp
coefsans = -0
0500 0
5333 -0
8167 1
0000 -0
0500 0
0833 1
0333 2
0000 -0
0500 -0