does parfor support global variables?
Afficher commentaires plus anciens
I want to use global variables in the functions run in parallel using parfor. Is it possible?
Réponses (1)
Edric Ellis
le 26 Mar 2012
0 votes
There are two restrictions.
- You cannot place a GLOBAL declaration directly inside a PARFOR loop
- The MATLAB workers executing the body of your PARFOR loop are separate MATLAB processes, and the values of global variables are not synchronised
So, while you can use GLOBAL variables within functions called from the body of your PARFOR loop, they probably do not behave as you wish.
Catégories
En savoir plus sur Loops and Conditional Statements dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!