how to do thread in matlab? i want to run one function on two variables simulatniosly how to do it?
+5
A:
The parallel toolbox has some tools that might help you. Find below some example pasted from the Matlab help
matlabpool % Use default parallel configuration
spmd % By default uses all labs in the pool
INP = load(['somedatafile' num2str(labindex) '.mat']);
RES = somefun(INP);
end
Then the values of RES
on the labs are accessible from the client as RES{1}
from lab 1, RES{2}
from lab 2, etc.
You might also look at parfor
as a simple parallel replacement of for
. Hope this helps even if it's not exactly what you're looking for.
Adrien
2010-04-26 12:17:58
+1
A:
I do not believe there is any built in multithreading support from MATLAB. This comes from both a conversation I had with a coworker recently and a quick google search
Hope this helps.
CrimsonX
2010-04-26 15:14:35
Yes. It is one of the problems with using Matlab to produce production apps.
mmr
2010-04-26 15:18:18
More and more of Matlab's native functions are multi-threaded with each new release to take advantage of multi-core CPUs. But the whole philosophy of tools like Matlab is against giving users hands-on access to threads and the like.
High Performance Mark
2010-04-26 15:47:59
From the Matlab help: There is either "implicit multiprocessing" which makes use of built in multi-threaded functions or "explicit multiprocessing" for which you have to use the parallel computing toolbox.
Adrien
2010-04-26 16:36:17