How can I use multithreading in Matlab?
276 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Adriano Gendy
el 18 de Mzo. de 2020
Respondida: Ed Mitchell
el 14 de Mzo. de 2023
Hi everyone
I have this sample code here:
a=0;
x = 0;
m = 0;
while (a==0)
m = m+1;
end
for i = 1:60
pause (1)
x = m;
if (i == 60)
a = 1;
end
Is there a way to make the two loops "communicate" with each other at the same time? So that I can update the x value with the m value continuosly?
Thanks in advance
2 comentarios
Respuesta aceptada
Ed Mitchell
el 14 de Mzo. de 2023
For people that are finding this MATLAB answer while searching more generally for how MATLAB manages the number of cores and hyperthreading, please refer to the following MATLAB Answer for more details.
0 comentarios
Más respuestas (1)
Dinesh Yadav
el 23 de Mzo. de 2020
Hi, there are two for loops in the above code. The way MATLAB multi-threading works in case of for loops is it checks for loops and dependent variables between for loops. If there is no dependency they will be parallized otherwise they remain in serial execution. In case of above code as variable x is dependent on m these for loops cannot be parallized.
Also go through similar questions links below asked in community .
0 comentarios
Ver también
Categorías
Más información sobre Startup and Shutdown en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!