Good day, I'm having problems saving inside a parfor loop. What I want to do is to save the results (vector results) from 5000 -> 5000 iterations (parfor loop takes 1 week to complete and I don't want to lose all the temporary result in case that something bad happens with the machine, i.e. reboot, power off..) A simplified version of my code is:
parfor ii = 1:100000 [output1, output2] = MyFunction(~,~,ii)
% from 5000 to 5000 iterations I want to save the vector results
if ii == 1:5000:100000 parsave('results.mat',output1, output2)
% now I want to save the final results
elseif ii == 100000 parsave('results.mat', output1, output2) endend
Maybe someone can provide me with an useful parfor.m function, or a way to save it using matfile objects (I don't know how to use them)
Best Answer