- at each iteration of your parfor loop, you log your progress into a file and then, if MATLAB or Windows crashes, you read that file.
- you use the DataQueue class to send back data to your main MATLAB process and you log the information in a file (see this documentation).
Saving and resuming the parfor states
12 次查看(过去 30 天)
显示 更早的评论
Is it possible to save the states of parfor loop, stop/break and restart from the same state. For example, in may case some time Windows crashes and I can not run the simulaiton from the same state, I have to run from initial level. In a simple for loop, I can save the variable i and ourval then I can run the for loop. In the code shown below, I have only variable i chaning in the parfor. Can I save parfor states after some interval and after restarting Matlab I can have all the variables in the wokspace resume parfor from same states.
% cubeL=51;
% XYZw=[90 100 108];
% P_labs, xyz nx3 matrix
% some_function is a function
ourval=zeros(size(xyz));
parfor i=1:cubeL*cubeL*cubeL
ourval(i,:)= some_function(xyz(i,:),P_labs,rgb,XYZw);
endd
0 个评论
采纳的回答
Nicolas B.
2019-8-26
Hi Imran,
I would suggest 2 solutions:
Does it helps you?
2 个评论
Nicolas B.
2019-8-27
Hi,
I haven't much time so I haven't tested your code. However, when calling a parfor loop, you must already have created the data at the right size (no resizing in parfor for common data). So try to create ourval before parfor.
For the code 2, try to write send(q, num2str(i)) in the loop instead of what you have. If what I suspect is right, I think that it should call disp(i) at the end of each loop.
I let you try. If I find time this afternoon, I will try to run your code.
Regards
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!