MATLAB slice函数的问题
输入指令SiW(12,12,9,4,4,3)后:,报错如下:
??? Error using ==> interp3 at 129
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);
Error in ==> SiWeiSM1 at 43
slice(x,y,z,D,[0:0.005:numxx],[0:0.005:numyy],[0:0.005:numzz])
代码如下:
function SiW(numxx,numyy,numzz,Xb,Yb,Zb)
A = csvread('C:\Users\Administrator\Desktop\test13.txt'); %读取txt
% A = numt;
B = reshape(A,Xb,Yb,Zb)
% Z = numx+numy+numz
% B = reshape(A,4,4,3) %变化为3维矩阵
C = permute(B,[2 1 3]) %将二维矩阵转置
D = C
[m,n,o]=size(D) %取三维的维度
%xx = mod(o,2); %判断z为奇偶,后边调整矩阵用
%if(xx == 1)
for q=1:2:o %三维z为奇数页时每页(二维)的偶行翻转
for i=2:2:m
D(i,:,q)=fliplr(D(i,:,q))
end
end
for q=2:2:o %三维z为偶数页时每页(二维)的奇行翻转 +上下翻转
for i=1:2:m
D(i,:,q)=fliplr(D(i,:,q))
end
D(:,:,q)=flipud(D(:,:,q))
end
% v=csvread('C:\Program Files\MATLAB\R2008a\vdata.txt');
% v=reshape(v,5,27,6);
% [x,y,z]=meshgrid(1:Xlength:numxx,1:Ylength:numyy,1:Zlength:numzz); %坐标系
[x,y,z]=meshgrid(1:1:Xb,1:1:Yb,1:1:Zb);
h2=figure(2);
set(h2,'name','四维空间','MenuBar','none','ToolBar','none')
slice(x,y,z,D,[0:0.005:numxx],[0:0.005:numyy],[0:0.005:numzz])
shading interp
colorbar
colormap('jet')
set(gca,'zdir','reverse');
axis equal
grid on
box on
% end