MATLAB 2021b has added multi-threaded programming as a core language feature

Traditionally, MATLAB code runs serially, with each function completing before the next can begin. It has been possible to use the Parallel Programming toolbox, although that is more focused on running analysis in parallel. With MATLAB 2021b a major update to the language is the addition of parallel function evaluation (parfeval), and the frameworks to run background tasks (futures) as a core feature:

https://www.mathworks.com/help/matlab/background-processing.html

This may help when designing experiment code where you want to run a background task without blocking your main control loop.

Yes, but my reading of the functionality implied this will generally only work for computational functions in M-Files, probably not for things like external mex files, ie. PTB functions. Haven’t tested it though, since i only have Matlab R2021b up and running since today, after being without a Matlab license for the last 3 months.

-mario

I haven’t yet tested parfeval yet either. But even if we can’t run mex files, running PTB on the main thread, and any accessory functions (for example, plotting online results) on a seperate thread could still be useful if it all works as hoped.