2017-06-12 63 views
0

我想繪製邊長爲10的立方體,這將是對稱-5到5,而不是-6〜4情節立方體在MATLAB

xc=1; yc=1; zc=1; % coordinated of the center 
L=10;     % cube size (length of an edge) 
alpha=0.8;   % transparency (max=1=opaque) 

X = [0 0 0 0 0 1; 1 0 1 1 1 1; 1 0 1 1 1 1; 0 0 0 0 0 1]; 
Y = [0 0 0 0 1 0; 0 1 0 0 1 1; 0 1 1 1 1 1; 0 0 1 1 1 0]; 
Z = [0 0 1 0 0 0; 0 0 1 0 0 0; 1 1 1 0 1 1; 1 1 1 0 1 1]; 

C='blue';     % unicolor 

X = L*(X-0.5) + xc; 
Y = L*(Y-0.5) + yc; 
Z = L*(Z-0.5) + zc; 

fill3(X,Y,Z,C,'FaceAlpha',alpha); % draw cube 
axis equal 
+0

你就不能設置'xc','yc'和'zc'爲0? – gnovice

回答

1

我剛纔設置的中心(0,0,0)得到期望的結果:

xc=0; yc=0; zc=0; % coordinates of the center 

enter image description here