I have a loop that is supposed to run a very long time that starts with a webread command. Sometimes there is something wrong with the page it’s trying to read which causes the script to stop and display the error. From what I understand you can put the command within a “try” command to continue despite the error like this:
try webread(‘www.something that could or could not generate an error.com’)catch continueend
First of all; is that the correct way of writing it or would I need to specify anything more after writing “catch”? And can I modify this so that instead of continuing the script it restarts it from the next iteration in the loop? If I write:
for i=1:100 try webread(‘www.something that could or could not generate an error.com’) catch end %I want this to cause the loop to jump up to the next value of i and restart the loop
endend
Matlab won’t understand what I mean with my double end statement. Is there some other way of doing this? I want my script to always ignore errors and just try again with a new iteration.
Best Answer