How to rotate an arrow in animation?
10 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Shuvagata Saha
le 29 Nov 2017
Réponse apportée : Bob Blaine
le 18 Déc 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
0 commentaires
Réponse acceptée
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.
0 commentaires
Plus de réponses (0)
Voir également
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!