Explanation

Global and persistent variables behave differently in parfor loops than in for loops. Because parfor loops run on many different MATLAB workers simultaneously, there are many different active workspaces and global contexts. Some assignments to global or persistent variables inside parfor loops affect only the value of the variable on the MATLAB client. Some assignments do not affect either the value of the variable on the MATLAB client or the value of the variable on the MATLAB workers.

In other words, the behavior of global and persistent variables within parfor loops can be surprising and using these variables inside parfor loops should be avoided.


Suggested Action

Change the program logic to not assign to global or persistent variables inside a parfor loop. For example, you can do either of the following: