Fact (from Matlab 2014 to Matlab 2016a rather than using the Parallell toolkit): Often the fastest code you can achieve with Matlab is to do nested functions, separating your variables between functions without passing them.
A step close to this uses global variables and splits your project into multiple files. This might slow performance a bit, because (presumably, although I have never seen this checked in any tests). Matlab takes overhead from a global workspace, and because there is some kind of problem (presumably, although no evidence of this has ever been seen) with JIT acceleration.
Thanks to my own testing, the transfer of very large data matrices (hi-images) between function calls, the use of nested functions or global variables is almost the same in performance.
The reason you can get superior performance with global variables or nested functions is because you can avoid additional data copying this way. If you send a variable to a function, Matlab does this by reference, but if you change a variable in a function, Matlab makes a copy on the fly (copy on write). I do not know how to avoid this in Matlab, with the exception of nested functions and global variables. Any small leak that you get from obstacles to JIT or global sampling time is completely achieved, avoiding this extra data copy (when using big data).
It may have changed with nothing from the versions of Matlab, but from what I hear from friends, I doubt it. I can not imagine any test, I no longer have a Matlab license.
As proof, look no further than the video processing toolbar that I made that day when I was working with Matlab. This is terribly ugly under the hood because I was not able to get performance without globals.
This fact about Matlab (that global variables are the most optimized way that you can code when you need to modify big data in different functions) is a sign of the need to update the language and / or interpreter.
Instead, Matlab can use a better, more dynamic view of the workspace. But none of what I saw says this. Especially when you see that the user community seems to ignore the facts and put forward oppions for no reason: for example, using globals in Matlab is slow.
This is not true.
However, you should not use global variables. If you are forced to process real-time video in pure Matlab, and you find that you have no other choice to use the global features to achieve performance, you should get a hint and change the language. Its time to switch to higher-performing languages ... and also, perhaps, write a random analysis about stack overflows, in the hope that Matlab can be improved by swaying opponents of its users.