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

7 views (last 30 days)
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 Comments
J. Alex Lee
J. Alex Lee on 29 Mar 2021
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"

Sign in to comment.

Accepted Answer

darova
darova on 31 Mar 2021
Edited: darova on 31 Mar 2021
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 Comments
darova
darova on 5 Apr 2021
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

Sign in to comment.

More Answers (0)

Categories

Find more on 2-D and 3-D Plots 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!