How to rotate an arrow in animation?

9 ビュー (過去 30 日間)
Shuvagata Saha
Shuvagata Saha 2017 年 11 月 29 日
回答済み: Bob Blaine 2017 年 12 月 18 日
I am trying to create an animation showing the rotation of an arrow about the centre. The arrow is to rotate 360 degree. Which function do I have to use to show the animation? The code is given below:
if true
clc; close all;clear all;
t = 0: (2*pi) / 100: 2*pi; %Creating points
a = cos(t) + sin(t)*i; %Finding the points
compass(a); %Creating the arrow
end

採用された回答

Bob Blaine
Bob Blaine 2017 年 12 月 18 日
Hi Shuvagata,
MATLAB graphics doesn't directly have an animation function, but a fairly simple 'for' loop can be implemented to do animations:
if true
clc; close all;clear all;
t = 0: (2*pi) / 100: 2*pi; %Creating points
a = cos(t) + sin(t)*i; %Finding the points
for i=1:size(a,2)
compass(a(i));
drawnow;
end
The important part is to do the drawnow in the loop, so your graphics changes show up. Hope that helps.

その他の回答 (0 件)

カテゴリ

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