Search code examples
matlabplot

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


I need to plot a dome or half a sphere and be able to change the dimensions of the dome. I figured MATLAB would be my best choice.

any suggestions?

THanks


Solution

  • The SPHERE function generates x, y, and z coordinates for a spherical surface. You just have to remove points corresponding to the bottom of the sphere to make a dome. For example:

    [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