诸位先进好,小弟我近日在处理一笔资料,含xyz座标及其值v,
因为资料点不多,所以希望可以利用griddata指令将值做内插,
code如下:
x=unique(da(:,1));
y=unique(da(:,2));
z=unique(da(:,3));
xx=linspace(x(1),x(length(x)),length(x)*2);
yy=linspace(y(1),y(length(y)),length(y)*2);
zz=linspace(z(1),z(length(z)),length(z)*2);
[gx,gy,gz]=meshgrid(xx,yy,zz);
V=zeros(length(y),length(x),length(z));
for n=1:length(da(:,1));
xi=find(x==da(n,1,t));
yi=find(y==da(n,2,t));
zi=find(z==da(n,3,t));
V(yi,xi,zi)=da(n,4,t);
end
Va=zeros(length(yy),length(xx),length(zz));
Va=griddata(x,y,z,V,gx,gy,gz);
其中da矩阵为原始资料,每一直行分别代表x,y,z,v
那执行时的错误讯息如下:
Error using TriScatteredInterp
Data point coordinates have inconsistent dimension.
Error in griddata>linear (line 211)
F =
TriScatteredInterp(inargs{1}(:),inargs{2}(:),inargs{3}(:),inargs{4}(:));
Error in griddata (line 128)
vq = linear(inputargs,numarg);
Error in Slice_3D (line 25)
Va=griddata(x,y,z,V,gx,gy,gz);
不知道看了一下help跟矩阵大小都没有问题,
想请教各位先进我的code需要修正哪个部份呢?