如何用MATLAB画半球体,注意是三维立体,求源代码啊!求各位大神帮助。

如题所述

R=1; %球半径
n=30; %网格大小=[n/2+2,n+1];
theta = (-n:2:n)/n*pi;
phi = ([0,0:2:n])'/n*pi/2;
cosphi = cos(phi); cosphi(1) = 0; cosphi(end) = 0;
sintheta = sin(theta); sintheta(1) = 0; sintheta(end) = 0;

x = R*cosphi*cos(theta);
y = R*cosphi*sintheta;
z = R*sin(phi)*ones(1,n+1);
surf(x,y,z);
axis equal

追问

这个有底面吗?

还是只是一个曲面

大神求教

温馨提示:答案为网友推荐,仅供参考
相似回答