我正在进行断层扫描项目,我想使用meshgrid
和slice
绘制速度模型的三维切片。类似this或this
这是我的代码
c=100 %grid
r= 5 %radius
rt= 8 %height
for i = 1:c
for j = 1:c
for k = 1:c
jarak1 = sqrt(((i-1)-r)^2+((j-1)-r)^2);
jarak2 = sqrt((i-r)^2+((j-1)-r)^2);
jarak3 = sqrt(((i-1)-r)^2+(j-r)^2);
jarak4 = sqrt((i-r)^2+(j-r)^2);
jarak5 = k;
if (jarak1 < r) &&(jarak2 < r) &&(jarak3 < r) &&(jarak4 < r) && (jarak5 < (rt+1))
Vmodel(j,i,k)=1500;
end
end
end
end
[X,Y,Z] = meshgrid(0:c,0:c,0:c);
xslice = 50; yslice = 50; zslice = 50;
slice(X,Y,Z,Vmodel,xslice,yslice,zslice)
我期待一个圆柱体,而是收到了错误信息。
??? Error using ==> interp3 at 128
Matrices X,Y and Z must be the same size as V.
Error in ==> slice at 104
vi = interp3(x,y,z,v,xi,yi,zi,method);
有什么想法吗?