How can I create x number of circles and then animate them?
7 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Andreas T
el 25 de Sept. de 2016
Comentada: Andreas T
el 25 de Sept. de 2016
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 comentarios
Respuesta aceptada
Satuk Bugrahan
el 25 de Sept. de 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 ;
Más respuestas (1)
Image Analyst
el 25 de Sept. de 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 comentarios
Ver también
Categorías
Más información sobre Animation en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!