How can I plot Spherical Coordinates, showing R, Theta and Phi, like animated image attached? And Cylindrical Coordinates?
11 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
EngEdgarHS
el 29 de Mzo. de 2021
Comentada: darova
el 5 de Abr. de 2021
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 comentarios
J. Alex Lee
el 29 de Mzo. de 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"
Respuesta aceptada
darova
el 31 de Mzo. de 2021
Editada: darova
el 31 de Mzo. de 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 comentarios
darova
el 5 de Abr. de 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
Más respuestas (0)
Ver también
Categorías
Más información sobre Surface and Mesh Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!