How can I create x number of circles and then animate them?
7 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I want to let the user specify how many circles there are to be plotted, each circle having a different size and all of them are in the center of the plot. Then I want to animate them so each circle gets a random speed to a random direction in the 2D plot. Is this possible?
I made this function to generate n numbers of random triangles but I don't know how to animate them with a certain speed and direction.
function circles(n)
for i = 1:n
size = randi(100);
pos = -size/2;
rectangle('Position',[pos pos size size],'Curvature',[1 1]);
end
0 commentaires
Réponse acceptée
Satuk Bugrahan
le 25 Sep 2016
function circles(c)
rectangle('Position',[-250 -250 500 500]);
size =randi([1,100],1,c);
k=-size/2 ;
l=-size/2 ;
m=-10+20*rand(1,c);
n=-10+20*rand(1,c);
for i=1:20
for a =1:c
r(a)=rectangle('Position',[k(a) l(a) size(a) size(a)],'Curvature',[1 1]);
k(a)=k(a)+m(a);
l(a)=l(a)+n(a);
end
refreshdata;
pause(.1);
if i==20
continue
end
delete(r(1,:))
end
After hours of dedicated work , I just wrote it as a beginner Matlaber. This would do it .Cheers ;
Plus de réponses (1)
Image Analyst
le 25 Sep 2016
Why not use viscircles() in the Image Processing Toolbox.
With your code, you'll need to add these lines after you call rectangle():
drawnow;
pause(0.3);
0 commentaires
Voir également
Catégories
En savoir plus sur Animation dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!