clc;clear;
figure(1);
[x y z]=sphere(50); %球由50*50的球面组成
surf(2*x,2*y,2*z,'FaceColor',[1,0,0]); %画一个圆心在(0,0,0),半径为2的球,并设置其颜色为红色
hold on %保持该图形的位置
[x y z]=sphere(50);
surf(2*x,2*y,2*(z-2),'FaceColor',[1,0,0]);
hold on
[x y z]=sphere(50);
surf(2*x,2*y,2*(z-4),'FaceColor',[1,0,0]);
hold on
[x,y,z]=cylinder(0.04); %生成一个半径为0.04的柱状体
z(2,:)=10; %柱状体的高度
surf(2*x,2*y,z-15,'FaceColor',[1,1,1]) %画出该柱状体图形 ,颜色为黑色
daspect([1,1,1]); %将x,y,z坐标轴设置为等长
view(50,30); %设置一个好的观察角度
rotate3d; %设置图形可旋转