MATLAB: Do I get an invalid dimensions error using TriScatteredInterp

interpolationMATLAB

I'm using TriScatteredInterp for 3 dimensional interpolation.
I have 3 variables xd,yd,zd of size 151:3 and I want to interpolate the values of z of size 31:25 for the given input values of x and y size 31:25.
If i run this program:
xd1=xlsread('3dcr.xls',1);
xd2=xlsread('3dcr.xls',7);
xd3=xlsread('3dcr.xls',3);
xd=[xd1,xd2,xd3];
yd1=xlsread('3dcr.xls',5);
yd2=xlsread('3dcr.xls',9);
yd3=xlsread('3dcr.xls',6);
yd=[yd1,yd2,yd3];
zd1=xlsread('3dcr.xls',2);
zd2=xlsread('3dcr.xls',8);
zd3=xlsread('3dcr.xls',4);
zd=[zd1,zd2,zd3];
f=TriScatteredInterp(xd,yd,zd);
for i=1:31
for j=1:25
v(i,j)=20;
b(i,j)=0.9;
end
end
zz=f(v,b)
I get this error:
??? Error using ==> TriScatteredInterp
Input data point locations have invalid dimension.
Error in ==> Untitled at 13
f=TriScatteredInterp(xd,yd,zd);

Best Answer

As Jiro pointed out xd, yd, zd should be column vectors. Whereas you're doing:
xd=[xd1,xd2,xd3];
yd=[yd1,yd2,yd3];
zd=[zd1,zd2,zd3];
Try to use:
f=TriScatteredInterp(xd(:),yd(:),zd(:))
Then it's not clear what the loop after is for...
Oleg