I want to draw sphere ?

2 ビュー (過去 30 日間)
Arvind Kumar Pathak
Arvind Kumar Pathak 2017 年 6 月 6 日
回答済み: KSSV 2017 年 6 月 6 日
I have this code
r = 1;
xo = 0;
yo = 0;
zo = 0;
m =20;
n = 10;
for theta=0:2*pi/m:2*pi, phi=-pi/2:pi/10:pi/2
x = xo + r *cos(phi)* cos(theta)
y = yo + r *cos(phi)* sin(theta)
z = zo + r *sin(phi)
end
i want get coordinates of x, y, z at each point on the sphere.
here i am changing the values of thera and phi in same for loop.
IS ir right? please help me.

採用された回答

KSSV
KSSV 2017 年 6 月 6 日
r = 1;
xo = 0;
yo = 0;
zo = 0;
m =20;
n = 10;
theta=0:2*pi/m:2*pi ;
phi=-pi/2:pi/10:pi/2 ;
[T,P] = meshgrid(theta,phi) ;
X = xo + r *cos(P).* cos(T);
Y = yo + r *cos(P).* sin(T);
Z = zo + r *sin(P) ;

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeWrite Unit Tests についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by