I am trying to retrieve a variable I executed on a parfor (parallel for) on MATLAB but I can’t. Heres my code:
clear all
clc
matlabpool open 4
parfor i = 1:4
a = 2^i;
end
matlabpool close
I would like to be able to recover the different values that were executed on the different workers. For example, I would like to access a(1) with a value of 2^1, a(2) with a value of 2^2, and so on. Thank you very much!
You can’t have multiple values when you are overwriting a single variable
a, Try instead:and there are good examples of how to use
parforin matlab documentation of it here.