If we use Parfor
in MATLAB (parallel computing) we can't save values or workspace using Save('My_workspace')
. Besides that if we simply remove ;
in every line in For
loops MATLAB show the output in command window
but in Parfor
nothing will appear. Everything in For
loop is normal but when I change For
to Parfor
I will get some errors so I need check stream of data and processes in Parfor
.
I want check steam of processes and data as I can see in For
loop. How can I do these in Parfor
structure?
Thanks.
save
is not allowed in parfor
. According to this article, the transparency is violated. However you can get around this with a function, as a function has its own stack, as shown in this post
parfor ii = 1:4
x = rand(10,10);
y = ones(1,3);
parsave(sprintf('output%d.mat', ii), x, y);
end
function parsave(fname, x,y)
save(fname, 'x', 'y')
end
The answer to another issue with command window output is "you just can't". See Mathworks' documentation (in the last section, Displaying Output), and the answer is "no".