回 帖 发 新 帖 刷新版面

主题:帮帮忙,如何绘制球面图????

x^2+y^2+z^2=r^2
这个球面应如果绘制出来呢???我只懂两个参数的,这个不会!

回复列表 (共3个回复)

沙发

我也有同样的问题 比如要画锥面和抛物曲面时,该怎么办啊 哪个高手来帮下忙

板凳

(1)我的土方法,呵呵,先画出上半球,再画下半球,假定半径为1,即x.^2+y.^2+z.^2=1,
>> clear;
>> x=-1:0.1:1;
>> y=-1:0.1:1;
>> [X,Y]=meshgrid(x,y);
>> Z1=(1-X.^2-Y.^2).^(1/2);
>> Z2=-(1-X.^2-Y.^2).^(1/2);
>> surf(Z1);上半球
>> hold on
>> surf(Z2);下半球

3 楼

clear,clc
r=5;
[x,y]=meshgrid(-r-r/100:r/115:r+r/100);
z=(sqrt(r^2-x.^2-y.^2));
n=size(z);
for i=1:n
    for j=1:n
        if ~isreal(z(i,j)) & imag(z(i,j))>.75
            z(i,j)=nan;
            z1(i,j)=nan;
        else
            z(i,j)=real(z(i,j));
            z1(i,j)=-real(z(i,j));
        end
    end
end
mesh(x,y,z)
hold on
%surf(x,y,z)
mesh(x,y,z1)
%surf(x,y,z1)
axis tight
shading interp
alpha(.9)

我来回复

您尚未登录,请登录后再回复。点此登录或注册