Restart variable from a middle point

Hi,
I have a for loop for a variable, let's call it X=linspace(a,b,c);
Now, imagine that I am calculating a variable M that depends on the values of X and suddenly Matlab stops.
How can I be sure that I store M until that point?
How can I restart the loop from the exact point that the calculation stopped?
Thanks in advance!

답변 (1개)

Matt J
Matt J 2019년 2월 11일

0 개 추천

You could save M to a .mat file in every iteration of the loop. That will slow things down, however.

댓글 수: 3

A_V_G
A_V_G 2019년 2월 11일
But then how could I restart it from a specific point?
Matt J
Matt J 2019년 2월 11일
편집: Matt J 2019년 2월 11일
You could save the iteration number as well. That way you would know where it stopped and you could re-launch the loop from that point.
load dumpFile M X lastIteration
for x=X( lastIteration+1:numel(X) )
...
end
Why do you expect Matlab to suddenly stop?
A_V_G
A_V_G 2019년 2월 11일
I am using a cluster and sometimes it is not realiable.
Therefore I need to be sure that if I have to make 5000 calculations and it stops after 3000, that I can restart it from that point.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

질문:

2019년 2월 11일

댓글:

2019년 2월 11일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by