Stuck in a while loop, want to revert back to previous menu.
Show older comments
Hi Matlab Community, if you see in my code below I would like to display an error message if the incorrect option is chosen in my menu. I would also like it to revert to the choices again after displaying said error message. as it stands everytime I run the script and the error message displays it get stuck in a loop.
I am very new to matlab, so any help is greatly appreciated.
choice = menu('Where are you travelling from?','Mercury','Earth','Jupiter');
if choice == 1;
choice = menu('Where are you travelling to?','Mercury','Earth','Jupiter');
while choice==1
disp('ERROR - You have chosen this planet as your start point, please choose a destination that is different from your start point');
end;
1 Comment
Thomas Brown
on 2 Dec 2016
Edited: Image Analyst
on 2 Dec 2016
Answers (0)
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!