MATLAB: How to tell matlab to automatically use all available cores — Matlab 2012

parallel computingParallel Computing Toolboxparfor

Hi, I am using Matlab 2012 on different machines – my work computer and my home computer. Both machines have different number of cores. I use parallel computing to speed up some parts of the computation and I'd like to adapt my code so that it would use the max number of cores on a machine.
For my work machine, I type in "matlabpool open local 8" whereas for my home machine I type in "matlabpool open local 2".
May I know how I can modify this code so that I can run the same code on both machines without manually having to change the maximum number of workers used?
Thanks!

Best Answer

If you do not specify the number of cores to use, then the default for the 'local' profile is the number of cores on the host. So you could just remove the number.
Note: if your system has hyperthreading turned on, then the default for the 'local' profile is still only the number of actual cores, not the number of the number of threads that could be used if you hyperthreaded.