I want to draw sphere ?

4 Ansichten (letzte 30 Tage)
Arvind Kumar Pathak
Arvind Kumar Pathak am 6 Jun. 2017
Beantwortet: KSSV am 6 Jun. 2017
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.

Akzeptierte Antwort

KSSV
KSSV am 6 Jun. 2017
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) ;

Weitere Antworten (0)

Kategorien

Mehr zu Write Unit Tests finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by