How to rotate an arrow in animation?

10 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Animation 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by