Periodically save matrixes (or workspace) within PARFOR loop
Afficher commentaires plus anciens
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)
Réponses (1)
Stephen23
le 14 Mar 2020
1 vote
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).
Catégories
En savoir plus sur Loops and Conditional Statements dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!