How not to repeat the whole code after the try catch loop ?
Ältere Kommentare anzeigen
Hi all
is there a line to indicate the main code between the try catch loop to avoide rewriting it ?
5 Kommentare
What is a try catch loop? try catch means branching in case of errors, but there is no loop. What is "the main code" and what might "between the loop" mean? For "between" there need to be at least 2 limits, but "between the loop" is only one.
"Between the bag there sat a man."
Please post some code, which demonstrates, what you are asking for. Prefer to edit the question instead of adding this information in a comment.
farzad
am 27 Jun. 2019
Jan
am 27 Jun. 2019
What does "how the structure is suggested" mean? If you are interested in assistance to solve your problem, it is useful to answer the questions for clarifications.
farzad
am 28 Jun. 2019
Jan
am 28 Jun. 2019
@farzad: You can be more clear: Simply explain, which problem you want to solve.
In this code:
for j = 1:10
try
... your code...
catch
warning('found error in %dth file', j);
continue
end
end
you do not have to write any code twice. The first comment (green line) is a placeholder for your code, and the second comment is some other code, which is executed only, if the first one ran without an error. An alternative version of the above code:
for j = 1:10
try
... your code...
... your code, if the above statement succeed
catch
warning('found error in %dth file', j);
end
end
So do you see now, that you do not write anything twice here?
You still did not mention, which problem you want to solve and you assume that anything must be written twice. My questions for clarifications are not answered yet.
You are not a newcomer in this forum, but please let me ask you to read this again: How to ask a good question
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!