It seems possible to run Matlab as a "Local Out-of-Process Server" from within Matlab. (I take for granted that Windows will run it in a different core.) So far I run this example, which displays "4".
h = actxserver('Matlab.Application'); msg = h.Execute('a = 2+2;'); a = h.GetVariable( 'a', 'base' ); disp( a ) delete(h)
The idea is to let the user start certain tasks and do something else in the application while the local out-of-process server works in the "background".
Now I wonder whether it is worth while to try to implement this. Which are all the problems and limitations I didn't think of?
The Matlab function, SYSTEM, might be an alternative. However, that has the overhead of starting Matlab for every task.
-------- EDIT ----------
I trippled my example:
h1 = actxserver('Matlab.Application'); h2 = actxserver('Matlab.Application'); ...
and learned that only one server is started; h1 and h2 are handles of the same server instance. That came as a surprise to me. I guess it's fundamental to the COM-technology. The Matlab documentation doesn't say that explicitly(?)
--- Wishful thinking ---
I learned from the tech support that
It is not possible to return control to the MATLAB command window while invoking a COM method of an actxserver application.
Thus, it is not possible to run jobs in the background with help of a local out-of-process Matlab server. However, there is an enhancement request.
The method is fine, if you have enough RAM to run two instances of MATLAB. Using SYSTEM allows to start more instances, which would use the cores more efficiently.
If the bottlenecks of your program are multi-threaded (e.g. MIN, MAX, FILTER, etc), all cores are occupied already and there will be no speedup.