How to rotate an arrow in animation?

10 vues (au cours des 30 derniers jours)
Shuvagata Saha
Shuvagata Saha le 29 Nov 2017
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

Réponse acceptée

Bob Blaine
Bob Blaine le 18 Déc 2017
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.

Plus de réponses (0)

Catégories

En savoir plus sur Animation dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by