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

조회 수: 13 (최근 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