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!