I am writing matlab code for Bilinear and Trilinear Interpolation (Numerical Aalysis/Methods). It uses following formula to approximate a function at reqired values of x, y and z
I have a code which calculates all the Lagrange Coefficients but I'm not able to substitute all the values in above formula. Also, all the values of vectors x, y and z are yto be substituted in f(x,y,z) as can be seen in the formula
syms x y Zx = [0.05 0.06];y = [1.23 1.41];z = [0.1 0.2];w=length(x);u=length(y);t=length(z);l=w-1;L=zeros(w,w);for k=1:l+1 A=1; for j=1:l+1 if k~=j A=conv(A,poly(x(j)))/(x(k)-x(j)); end end L(k,:)=A;endLM=zeros(u,u);m=u-1;for k=1:m+1 B=1; for j=1:m+1 if k~=j B=conv(B,poly(y(j)))/(y(k)-y(j)); end end M(k,:)=B;endMn=t-1;N=zeros(t,t);for k=1:n+1 C=1; for j=1:n+1 if k~=j C=conv(C,poly(z(j)))/(z(k)-z(j)); end end N(k,:)=C;endN
Matrices L, M and N represent Lagrange polynomials in each row.
This is what my code looks like.
Can anyone help me writing the code for substituting all the values required in above formula.
Best Answer