ncores = 12; matlabpool('open', 'local', ncores); % another form of matlabpool wi = zeros(1,1000); parfor k=1:1000 w = getCurrentWorker; wi(k) = get(w, 'ProcessId') end matlabpool('close'); pid = unique(wi); core = zeros(1, 1000); for k=1:ncores core(wi == pid(k)) = k; end plot(core, 'o') title('Allocation of CPUs') xlabel('Index') ylabel('CPU ID/core')