Restart script at specific line if faults
5 次查看(过去 30 天)
显示 更早的评论
Is there a way for me to restart a script if the script gets a faulty value?
For example, if a is a value that if reached I want to restart the script at a specific line, is there a way to do it like this:
if x=a
% restart from line 3
end
Thanks.
0 个评论
回答(1 个)
Walter Roberson
2019-12-3
No.
while true
if ~exist('restarting', 'var')
restarting = false;
end
if ~restarting
all of the lines before the target line go here,
the ones that are to be skipped on restart
else
restarting = false;
end
the lines after the target lines go here
at some point when the "faulty value" is found
restarting = true;
end
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!