I want to draw sphere ?
4 次查看(过去 30 天)
显示 更早的评论
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
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Write Unit Tests 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!