Three loops running in parallel simultaneously
Mostrar comentarios más antiguos
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 comentarios
Jan
el 22 de Oct. de 2018
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
el 22 de Oct. de 2018
Jan
el 22 de Oct. de 2018
I do not see a reason to run the loops "in parallel".
MOTHANA LAFTA
el 23 de Oct. de 2018
Editada: MOTHANA LAFTA
el 23 de Oct. de 2018
Respuestas (0)
Categorías
Más información sobre Programming en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!