代码之家  ›  专栏  ›  技术社区  ›  dewalla

如何在MATLAB中绘制不同半径的圆顶?

  •  1
  • dewalla  · 技术社区  · 15 年前

    [x,y,z] = sphere;      %# Makes a 21-by-21 point sphere 
    x = x(11:end,:);       %# Keep top 11 x points 
    y = y(11:end,:);       %# Keep top 11 y points 
    z = z(11:end,:);       %# Keep top 11 z points 
    r = 3;                 %# A radius value 
    surf(r.*x,r.*y,r.*z);  %# Plot the surface 
    axis equal;            %# Make the scaling on the x, y, and z axes equal 
    

    Does anyone know how to plot a dome (aka half sphere) in MATLAB...or anyother programming language?

    如何更改代码?

    1 回复  |  直到 9 年前
        1
  •  2
  •   Jonas    15 年前

    我们把半径叫做x,y,z rx ry ,和 rz 分别是。

    然后像这样调用函数

    [x,y,z] = sphere;      %# Makes a 21-by-21 point unit sphere 
    x = x(11:end,:);       %# Keep top 11 x points 
    y = y(11:end,:);       %# Keep top 11 y points 
    z = z(11:end,:);       %# Keep top 11 z points 
    rx = 3;ry = 4;rz = 9;  %# Define rx, ry, rz
    surf(rx*x,ry*y,rz*z);  %# Plot the surface, multiplying unit coordinates with radii 
    axis equal;            %# Make the scaling on the x, y, and z axes equal