Three loops running in parallel simultaneously
이전 댓글 표시
Hello all. I am assigned to make a program in which multiple loops need to be executed at the same time and increment two counters simultaneously based on a certain condition for example: note, I tried with parfor but I confuse how to solve this issue
if true
N_M_O1=10;
N_M_O2=12;
N_M_O3=13;
conter_B1=0;
conter_B2=0;
x=[2 3 5 8 6 3 4 5 8 9];
y=[2 3 6 5 2 9 4 6 3 5];
x2=[2 8 5 8 6 3 6 5 6 9 10 12];
y2=[9 3 6 9 7 9 4 6 8 5 1 23];
x3=[2 3 1 8 6 3 55 5 6 9 2 3 5];
y3=[2 4 6 4 6 5 4 6 6 4 12 32 3];
for m=1:N_M_O1
z(m)=x(m)+y(m);
if z(m)>10
conter_B1=conter_B1+1;
else
conter_B2=conter_B2+1;
end
end
for m=1:N_M_O2
z2(m)=x2(m)+y2(m);
if z2(m)>10
conter_B1=conter_B1+1;
else
conter_B2=conter_B2+1;
end
end
for m=1:N_M_O3
z3(m)=x3(m)+y3(m);
if z3(m)>10
conter_B1=conter_B1+1;
else
conter_B2=conter_B2+1;
end
end
end
댓글 수: 4
Jan
2018년 10월 22일
Matlab will run these loops sequentially. It is not meaningful to ask for a parallel processing. If the loops depend on each other, why not writing one loop instead of 3?
MOTHANA LAFTA
2018년 10월 22일
Jan
2018년 10월 22일
I do not see a reason to run the loops "in parallel".
MOTHANA LAFTA
2018년 10월 23일
편집: MOTHANA LAFTA
2018년 10월 23일
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Programming에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!