Is there a way to abort the code inside a function?
Ältere Kommentare anzeigen
Hey there,
Happy to know people are there when there is a challenge. I see that return function is used to abort the code when it appears in the root level of an m-code. But when used in a function, it returns the program flow back to the invoking function.
Having this in mind, I wanna terminate the whole program when a sign of accomplishment is met inside a function. One way seems to be using return for several times to reach the root level. but what's so frustrating here is that this method implies checking the condition in each return again and again till getting into the root.
I know that error function would resolve the issue, but it's not sensible to produce an error when the code is successfully accomplished.
Please advise as necessary.
Akzeptierte Antwort
Weitere Antworten (1)
Chad Greene
am 9 Nov. 2014
0 Stimmen
Can you use a while loop with continue in your function?
1 Kommentar
Pouya Jamali
am 10 Nov. 2014
Kategorien
Mehr zu Programming finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!