Borrar filtros
Borrar filtros

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

7 visualizaciones (últimos 30 días)
Tino
Tino el 15 de Abr. de 2019
Comentada: Tino el 15 de Abr. de 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 comentarios
Dennis
Dennis el 15 de Abr. de 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')

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by