How can I get multiple for loops to run at the same time?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
%Points
P1=[-15,0];
P2=[-5,0];
plot([P1(1) P2(1)],[P1(2) P2(2)],'LineWidth',5,'Color','black');
A=[0,0];
circle=viscircles(A,5,'LineWidth',2,'Color','black');
pause(.5)
%Circle B
for b=0:pi/80:pi/8;
pause(.5)
B=A+[10*cos((-pi/8)+b), 10*sin((-pi/8)+b)];
circle2=viscircles(B,5,'LineWidth',2,'Color','green');
end
%Circle C
for c=0:pi/40:pi/4;
pause(.5)
C=B+[10*cos(-(pi/4)+c), 10*sin(-(pi/4)+c)];
circle3=viscircles(C,5,'LineWidth',2,'Color','blue');
end
0 comentarios
Respuestas (1)
Image Analyst
el 8 de Dic. de 2018
To get them to run at the same time, you have to run them on separtae CPU cores. To do that you need to use parfor (instead of for), which is in the Parallel Processing Toolbox.
0 comentarios
Ver también
Categorías
Más información sobre Startup and Shutdown 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!