フィルターのクリア

Plot a circle and a vector moving around it

35 ビュー (過去 30 日間)
Nathan Kennedy
Nathan Kennedy 2018 年 1 月 9 日
回答済み: Star Strider 2018 年 1 月 9 日
Hi
Draw a circle, then plot multiple vectors from the origin to the outline of the circle
angle = 0:0.05:2*pi
x = cos(angle)';
y = sin(angle)';
z = [x,y];
figure(1)
hold on
plot(x,y) % circle
for i = 1:length(angle)
plotv(z,'-') %plot vector for each angle
drawnow;pause(0.2);
end
but it is only drawing the same one one at 45 degrees

回答 (2 件)

KSSV
KSSV 2018 年 1 月 9 日
r = 1. ; % radius of circle
th = linspace(0,2*pi) ;
x = r*cos(th) ;
y = r*sin(th) ;
plot(x,y)
quiver(x,y,x,y)
  2 件のコメント
Stephen23
Stephen23 2018 年 1 月 9 日
+1 innovative use of quiver
Nathan Kennedy
Nathan Kennedy 2018 年 1 月 9 日
I don't think quiver is suitable as it plots all of them at the same time and drawnow cant be used?

サインインしてコメントする。


Star Strider
Star Strider 2018 年 1 月 9 日
Try this slight variation on your code:
figure(1)
AxH = axes('NextPlot', 'add');
plot(x,y) % circle
for i = 1:length(angle)
plot([0 z(i,1)], [0 z(i,2)],'-') %plot vector for each angle
axis([-1.1 1.1 -1.1 1.1])
axis equal
drawnow
pause(0.1);
end

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by