Effacer les filtres
Effacer les filtres

using return command before codes

2 vues (au cours des 30 derniers jours)
sermet
sermet le 6 Juin 2015
while (criterion for loop)
iteration=iteration+1;
%codes to perform
if iteration==200
errordlg('iteration cannot be converged', 'Error!', 'modal')
return
end
end
%other codes need to be performed independently after the above loop
%In this example, if iteration numbers reach 200, return command terminates the loop to eliminate infinite loop. But there are other codes right after the loop which need to be executed. How can I continue to execute other codes outside the loop with using return command.

Réponse acceptée

the cyclist
the cyclist le 6 Juin 2015
It sounds like you want the break command rather than return command. A similar one is the continue command, but I don't think that's what you want in this case.

Plus de réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by