Let X
contain the x-coordinates of your nodes, Y
the y-coordinates, Z
the z-coordinates of your nodes. Store the value/data at your nodes in V
. Now you can specify where you want to interpolate the data by saving the x,y and z-coordinates of these points in Xs
,Ys
and Zs
. The value of your data at these points is:
Vs = interp3(X,Y,Z,V,Xs,Ys,Zs,'linear');
You can take a look at the Matlab documentation.
Edit: As you added your code: The error seems to be that the dimension of your V
is wrong. If you take a look at the example Matlab Docu -> interp3 -> Evaluate Outside the Domain of X, Y, and Z you will see, that V
has to have the dimension as X
, Y
and Z
combined. From the documentation: size(V) = [length(Y) length(X) length(Z)]
for vectors X
,Y
and Z
.
Here is an example:
X = linspace(-1,2,5);
Y = linspace(-1,7,23);
Z = linspace(3,9,23);
V = rand(23,5,23);
xq = linspace(0,1,34);
yq = linspace(0,2,34);
zq = linspace(4,5,34);
vq = interp3(X,Y,Z,V,xq,yq,zq,'linear',-1);