how can i go back to the fist choose again with out termination after finshing the first task?
조회 수: 1 (최근 30일)
이전 댓글 표시
mynumber = input('Enter a number:');
switch mynumber
case -1
disp('negative one');
case 0
disp('zero');
case 1
disp('positive one');
otherwise
disp('other value');
end
hello every one
I wrote some code which repeatedly do some task
eg like this above which is in mat lab docc.
when I select the first choice(1}
the program does the first statement only and stops.what i want is ,after compelitilng the first task it should asks me again if i want to choose the choices starting from choice 1
how can i do that?
댓글 수: 0
채택된 답변
David Sanchez
2014년 6월 24일
Use a while-loop:
mynumber = 0;
while (mynumber ~= 3) % condition to get out of the loop. Change to your needs
mynumber = input('Enter a number:');
switch mynumber
case -1
disp('negative one');
case 0
disp('zero');
case 1
disp('positive one');
otherwise
disp('other value');
end
end
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Operators and Elementary Operations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!