MATLAB画3x3立方体,代码如下:
for i = 1:9
if((mod(i,3)==0))
ii = 2;
else
ii = mod(i,3)-1;
end
plotcube([1 1 1],[ 2+ii 2+ceil(i/3) 2],.8,[1 0 0]);
end
for i = 1:9
if((mod(i,3)==0))
ii = 2;
else
ii = mod(i,3)-1;
end
plotcube([1 1 1],[ 2+ii 2+ceil(i/3) 3],.8,[0 1 0]);
end
for i = 1:9
if((mod(i,3)==0))
ii = 2;
else
ii = mod(i,3)-1;
end
plotcube([1 1 1],[ 2+ii 2+ceil(i/3) 4],.8,[0 0 1]);
end
function plotcube(varargin)
% PLOTCUBE - Display a 3D-cube in the current axes
%
% PLOTCUBE(EDGES,ORIGIN,ALPHA,COLOR) displays a 3D-cube in the current axes
% with the following properties:
% * EDGES : 3-elements vector that defines the length of cube edges
% * ORIGIN: 3-elements vector that defines the start point of the cube
% * ALPHA : scalar that defines the transparency of the cube faces (from 0
% to 1)
% * COLOR : 3-elements vector th

最低0.47元/天 解锁文章
2730

被折叠的 条评论
为什么被折叠?



