How to display a menu if the entered value is true and at end of each option
Ältere Kommentare anzeigen
I am using a function to verify an entered value from csv file, so if the entered value is true the program should display a menu. If it is false it will display a message to re-enter a valid value from the csv file. How can I display the menu again after entering a false value then true one? I tried to use a while loop but it seems not working. I also want to display the menu at the end of each option in the menu. Any ideas about how to do so?
Antworten (1)
Prince Kumar
am 19 Jan. 2022
Hi,
You can do it using 'while' loop and 'break' statement. Once you have achieved the desired result you can use 'break' statement to get out of the loop.
Here is an example where the code keep asking for a number until the user enter 4 as input(which is the desired result) :
data = 4;
m = input('Enter a number : ');
while true
if m == data
disp('True');
break;
else
disp('False');
m = input('Enter a number : ');
end
end
I hope you find the above example useful.
Kategorien
Mehr zu Whos finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!