Periodically save matrixes (or workspace) within PARFOR loop

4 visualizaciones (últimos 30 días)
Boram Lim
Boram Lim el 13 de Mzo. de 2020
Respondida: Stephen23 el 14 de Mzo. de 2020
I have been using a parallel loop (Parfor) in Matlab, and here is part of my code. (It is supposed to run a few days so I want to save outputs periodically.
parfor i = 1:N
...
out1(i,:) = result1;
out2(i,:) = result2;
if mod(i,100) == 0
% Here, I want to save out1 and out2 (export with .mat file)
end
end
How can I save out1 and out2 for every 100th iteration? (Saving workspace for every 100th iteration is also okay)

Respuestas (1)

Stephen23
Stephen23 el 14 de Mzo. de 2020
Note that the order which the files are saved in is not guaranteed: the parfor iterations are not necessarily performed in the order i = 1:N, which also means that your code could end up saving files at very unequally distributed times during runtime (worst case: all iterations where mod(i,100)==0 are evaluated first/last).

Categorías

Más información sobre Startup and Shutdown en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by