필터 지우기
필터 지우기

How can I get multiple for loops to run at the same time?

조회 수: 1 (최근 30일)
Allison Bushman
Allison Bushman 2018년 12월 5일
다시 열림: madhan ravi 2018년 12월 12일
%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

답변 (1개)

Image Analyst
Image Analyst 2018년 12월 8일
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.

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by