How do I restart my code again if the conditions are not satisfied

6 vues (au cours des 30 derniers jours)
Tino
Tino le 15 Avr 2019
Commenté : Tino le 15 Avr 2019
Hi guys
Please is there any code that will make me restart a coding process. for instance I have a running code and finalised it with the if statement
if ( x > 1)
disp( ' yoga')
else
disp ( continue running the code until x > 1)
end
how do I run my previous code again until x > 1
Thanks in advance for you kind assistance
regards
  2 commentaires
Dennis
Dennis le 15 Avr 2019
In your example x never changes.
There are several ways to accomplish this. You could for example use loops or call your function again (recursive).
x=0;
while x<=1
%do stuff, there should be something here that actually changes the value of x!
end
disp('yoga')
Tino
Tino le 15 Avr 2019
Thanks Dennis

Connectez-vous pour commenter.

Réponses (0)

Catégories

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

Tags

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by