Periodically save matrixes (or workspace) within PARFOR loop
3 views (last 30 days)
Show older comments
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)
0 Comments
Answers (1)
Stephen23
on 14 Mar 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).
0 Comments
See Also
Categories
Find more on Startup and Shutdown in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!