MATLAB: How many cores does MATLAB use in a given program

coresMATLAB

This might be an odd question, but my code has to be run on a more powerful machine. What would be helpful is to know how many cores my program uses. I don't know how to obtain this information. Would anyone be able to provide some suggestions?

Best Answer

On my computer...
maxNumCompThreads
ans =
4
How many cores your code actually uses on any given code is far more difficult. MATLAB can sometimes launch extra threads for large problems, but ONLY if it decides there will be a gain in so doing. So any given code may vary in the number of cores it will end up using. With some effort, I can force all of my cores to run flat out, but most simple computations never launch any additional cores.
I would suggest that you test run your code, watching a system monitor that will tell how many cores are active for MATLAB. How you do that will depend on what computer you are using. On my Mac, it is the activity monitor utility that I would use.
Related Question