Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to do threading in MATLAB?

How to do threading in MATLAB? I want to run one function on two variables simultaneously. How do I do it?

like image 469
hai Avatar asked Feb 27 '23 03:02

hai


1 Answers

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.

like image 64
Adrien Avatar answered Mar 02 '23 15:03

Adrien