How can I plot Spherical Coordinates, showing R, Theta and Phi, like animated image attached? And Cylindrical Coordinates?
7 ビュー (過去 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
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
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
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 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!