matlabpool open n; doesn't work.
10 views (last 30 days)
Show older comments
Martin on 7 May 2014
Commented: Bruno Silva on 17 Jan 2020
I'd like to open matlabpool with a variable number of cores, to use the maximum number of cores available. So n would equal features('numCores') here.
But matlabpool open n, matlabpool open features('numCores'), matlabpool open maxNumCompThreads don't work here. matlabpool open seems to accept only numbers and not variables.
I could do something stupid like
if features('numCores') == 4
matlabpool open 4;
elseif features('numCores') == 2
matlabpool open 2;
but I'd like to know if something more elegant exists.
Niklas Nylén on 7 May 2014
Edited: Niklas Nylén on 7 May 2014
This is because writing arguments like this:
matlabpool open 2
is the same as passing the strings 'open' and '2' to the matlabpool function, i.e. the equivalent to
What you can do is to call matlabpool like this:
Possibly you can also pass the number of cores directly, but since I do not have parallell computing toolbox I can't test it, like so:
More Answers (2)
Matt J on 7 May 2014
Edited: Matt J on 7 May 2014
If you have R2013b or later, you shouldn't be using matlabpool . You should be using parpool , which does take a variable as input directly,
Malshikho on 25 May 2018
Unfortunately I have Matlab R2010b
Steven Lord on 25 May 2018
Then use matlabpool using the syntax described in the accepted answer by Niklas Nylén.
Find more on MATLAB Parallel Server in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!