[cc lang=”matlab”]
%上半球
figure;
[x,y,z]=sphere(30);
z(z<0)=nan; surf(x,y,z); [/cc]

[cc lang=”matlab”]
%右半球
figure;
[x,y,z]=sphere(30);
z(x<0)=nan; surf(x,y,z); [/cc]

[cc lang=”matlab”]
%上部分是半球，下部分是圆锥的合体
figure;
t=linspace(0,2*pi,37);
r=linspace(0,1,10);
[t,r]=meshgrid(t,r);
[x,y]=pol2cart(t,r);
surf(x,y,r);
hold on;
r=r*pi/2;
[x,y,z]=sph2cart(t,r,1+0*t);
surf(x,y,z+1);
axis equal;
[/cc]

[cc lang=”matlab”]
%半球面
figure;
[fia,theta]=meshgrid([linspace(0,pi,100),pi]);
x=sin(theta).*cos(fia);
y=sin(theta).*sin(fia);
z=cos(theta);
surf(x,y,z)
[/cc]

[cc lang=”matlab”]
%椭球面
figure;
theta=0:0.1:2*pi;
phi=theta’;
x=cos(phi)*cos(theta);
y=cos(phi)*sin(theta);
z=sin(phi)*ones(size(theta));
mesh(x,y,z);
[/cc]

[cc lang=”matlab”]
%双叶双曲面
figure;
ezsurf(‘8*tan(u)*cos(v)’,’8.*tan(u)*sin(v)’,’2.*sec(u)’,[-pi./2,3*pi./2,0,2*pi])
axis equal
grid on
axis square
xlabel(‘x轴’);ylabel(‘y轴’);zlabel(‘z轴’);
title(‘双叶双曲面’)
[/cc]

[cc lang=”matlab”]
%上半球显示为半透明效果
figure;
[x,y,z]=sphere(30);
z(z<0)=nan; surf(x,y,z,'FaceAlpha',0.5); %Alpha取值范围 0