Plotting a section of a hemisphere using parametric equations

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?

 採用された回答

David Goodmanson
David Goodmanson 2020 年 4 月 30 日

0 投票

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

2 件のコメント

Marcus Velling
Marcus Velling 2020 年 4 月 30 日
Works perfectly, thank you
darova
darova 2020 年 4 月 30 日

サインインしてコメントする。

その他の回答 (1 件)

Carlos Guerrero García
Carlos Guerrero García 2022 年 11 月 16 日

0 投票

Another way for changing the theta and/or phi values is
theta=[0:pi/36:2*pi];
phi=[0:pi/36:pi/4];
Anyway, I suggest not to create a vector for theta and another vector for phi only for making the meshgrid. I suggest changing that lines as follows:
[THETA,PHI]=meshgrid(0:pi/36:2*pi,0:pi/36:pi/4);
R=1;
X1=...

カテゴリ

製品

リリース

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by