Bilinear and Trilinear Interpolation
Mostra commenti meno recenti
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 Z
x = [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;
end
L
M=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;
end
M
n=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;
end
N
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.
3 Commenti
John D'Errico
il 26 Giu 2020
Modificato: John D'Errico
il 26 Giu 2020
Is there a reason why you are not using interp2, interp3 or just interpn? It is rarely a good idea to write inefficient code to do that which is already provided.
Jalal Hassan
il 27 Giu 2020
Jalal Hassan
il 27 Giu 2020
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Interpolation in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

