Clear Filters
Clear Filters

Menu function - would like menu to pop back up after choice made

3 views (last 30 days)
I am creating a pop-up menu as a final project for one of my courses. I am in the very beginning stages, here is what I have so far:
choice = menu('Statistical Analysis','Set username','Load data file','Clear data','Set output filename','Plot histogram','Plot histogram fit','Plot probability plots','Regression of y on x','Find probability (x or z)','Find x or z','Exit')
switch choice
case 1
username = input('Please input your username:\n','s')
case 11
close all
end
I have noticed after I select choice 1, to input username, I type in my username, and the menu itself closes. I would like the menu to re-open after a choice has been made, and only close once the exit option has been chosen.

Accepted Answer

Image Analyst
Image Analyst on 13 Apr 2017
Try putting it in a while loop:
choice = 1;
while choice ~= 11
choice = menu('Statistical Analysis','Set username','Load data file','Clear data','Set output filename','Plot histogram','Plot histogram fit','Plot probability plots','Regression of y on x','Find probability (x or z)','Find x or z','Exit')
switch choice
case 1
username = input('Please input your username:\n','s')
case 11
close all
end
end

More Answers (0)

Categories

Find more on MATLAB 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!