MATLAB: Plotting a section of a hemisphere using parametric equations

hemisphereMATLABmeshgridparametric equationsplotsurf

Using:
theta=[0:0.1:2*pi];
phi=[0:0.1:pi/4];
R=1;
[THETA,PHI]=meshgrid(theta,phi);
X1=R.*cos(THETA).*sin(PHI);
Y1=R.*sin(THETA).*sin(PHI);
Z1=R.*cos(PHI);
surf(X1,Y1,Z1)
I get a section of a sphere, but a slit is missing from the plot. How do i fill in the slit?

Best Answer

  • Hi Marcus
    theta=[0:0.01:1]*2*pi;
    ensures that the value of 2*pi is reached.