How can I plot an animated circle?

5 ビュー (過去 30 日間)
help_me
help_me 2017 年 12 月 8 日
回答済み: Jos (10584) 2017 年 12 月 8 日
I want to plot the radius of this circle going round (360 degrees) without the circle showing. So basically just a line fixed at the origin that spins for 2*pi.
I understand that I have to use a for loop between 0 to 2*pi but I don't get which variables I have to use.
Thanks

回答 (1 件)

Jos (10584)
Jos (10584) 2017 年 12 月 8 日
Calculate the endpoints
  • x = r*cos(2*pi*f*t)
  • y = r*sin(2*pi*f*t)
where r, is the radius, f is the frequency and t is the time.
figure
f = 0.3 ; % frequency
r = 2 ;
ph = plot(NaN,NaN,'b-o') ;
axis(1.1*[-r r -r r]) ;
axis square
tic
while(toc < 10)
t = toc ;
ph.XData = [0 r*cos(2*pi*f*t)] ;
ph.YData = [0 r*sin(2*pi*f*t)] ;
drawnow
end

カテゴリ

Help Center および File ExchangeAnimation についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by