I want to draw sphere ?
4 views (last 30 days)
Show older comments
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.
Accepted Answer
KSSV
on 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) ;
0 Comments
More Answers (0)
See Also
Categories
Find more on Write Unit Tests in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!