% Display how many threads Matlab thinks it can use
maxNumCompThreads()

% Set threads to be equal to number of cores requested
NSLOTS = str2num(getenv('NSLOTS'));
maxNumCompThreads(NSLOTS);

% Verify requested change happened
maxNumCompThreads()