How can I plot Spherical Coordinates, showing R, Theta and Phi, like animated image attached? And Cylindrical Coordinates?

4 次查看(过去 30 天)
I need to make an animation in which it would be possible to check the variation between R, Theta and Phi in the sphere as it varies from 0 to 2pi at one end and from 0 to pi at the other. Of course, R can be constant, but the idea is to make an animation just like the attached GIF. Honestly, I don't even know how to start doing that. Consequently, a particular case would be to animate a cylindrical coordinate. I hope you guys can clear my path.
  2 个评论
J. Alex Lee
J. Alex Lee 2021-3-29
i think a problem that you may not even know that you have yet, is how to get coordinates organized in such a way as to be able to represented as the mesh/surface you are seeing rather than a simple collection of points.
take a look at the functions "cylinder" and "sphere" for that.
then, you can interoperate between cartesian coordinates and spherical/cylindrical coordinates with the functions "cart2pol", "pol2cart", "cart2sph", "sph2cart"

请先登录,再进行评论。

采纳的回答

darova
darova 2021-3-31
编辑:darova 2021-3-31
Try this
clc,clear
t = 0:10:180;
[T,R] = meshgrid(0:10:360,0:10);
[X,Y] = pol2cart(T*pi/180,R);
Z = R;
h = surf(X,Y,Z);
for i = 1:length(t)
set(h,'xdata',X*cosd(t(i)));
set(h,'ydata',Y*cosd(t(i)));
set(h,'zdata',Z*sind(t(i)));
pause(0.2)
end
  4 个评论
darova
darova 2021-4-5
Sorry, deleted your comment for an instance
JUst draw lines
clc,clear
[x,y,z] = sphere(20); % sphere data
[x1,y1] = pol2cart((0:10:360)*pi/180,1); % circle data
surf(x,y,z,'facecolor','none','edgecolor',[1 1 1]/2)% plot sphere
h = line(x1,y1,x1*0,'color','k'); % draw circle
for t = 0:10:180
set(h,'xdata',sind(t)*x1)
set(h,'ydata',sind(t)*y1)
set(h,'zdata',cosd(t)*1+x1*0)
pause(0.1)
end

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Surface and Mesh Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by