MATLAB slice函数的问题

chengyouli8243 2018-09-15 07:18:51
输入指令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
...全文
857 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
chybeyond 2018-09-16
  • 打赏
  • 举报
回复
xyzd必须大小相同

69,374

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧