Periodically save matrixes (or workspace) within PARFOR loop
Ältere Kommentare anzeigen
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)
Antworten (1)
Stephen23
am 14 Mär. 2020
1 Stimme
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).
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!