How do I restart my code again if the conditions are not satisfied
3 次查看(过去 30 天)
显示 更早的评论
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 个评论
Dennis
2019-4-15
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')
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Startup and Shutdown 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!