How to reiterate the function automatically if my code stops working because my internet disconnected
1 次查看(过去 30 天)
显示 更早的评论
Hello,
I want to get weather data from a URL given below:
xdom = xmlread('http://api.openweathermap.org/data/2.5/forecast? q=Texel,NL&mode=xml&APPID=f3e1e8697d3d20e5d91f193ef02e4846')
Now my whole code is running properly, but due to bad internet connection my code stopped. To safeguard my whole code that it doesn't happen again, I want to develop a code which will help in reiterating the code after every 30 seconds until the internet connection is restored. Can someone help me with the same.
采纳的回答
Jan
2015-4-14
How does this code stop? With an error message? Then TRY-CATCH is a direct solution:
success = false;
while ~success
try
xdom = xmlread('...');
success = true;
catch ME
disp('Failed:');
disp(ME.message);
pause(30);
end
end
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!