Use C++ Objects and Functions in parfor
Loops
You can use the MATLAB®
parfor
function with a MATLAB interface to a C++ compiled library.
Call C++ non-member functions in a
parfor
loop. A non-member function, sometimes called a package function, is defined outside of a class definition.Create C++ objects in a parfor iteration and use them in the same iteration.
The following use cases are not supported.
C++ objects created outside a parfor loop cannot be used in the parfor loop.
C++ objects created in a parfor loop iteration cannot be used in another iteration or outside the parfor loop.
Your C++ library might not be a candidate for parallel computing. Parfor loop iterations run in different processes. If your code must run in the same process, then the result is not guaranteed.