Can I generate a menu of choices with a dialogue box that allows more than one of the options to be selected?

2 views (last 30 days)
I wish to display a menu with country names as the buttons. The idea is that I am running regressions of financial data in different countries, and I wish to be able to have the user interactively choose which countries he/she wants to represent in the data (think EM, EU countries, developed nations...there mnay goruping that would be useful). Ideally, pressing one of the buttons would switch the corresponding element in an array of logicals to true. A button not being pressed would leave the element as false (i would preallocate an array of false's of length equal to the number of countries). This would allow me to inpt this array of logicals into an array of all country names, returning only those names that would be used in the regression. Some code would be more than appreciated, but really I am just hoping to know if this is even possible, and what sort of built in functions besides inputdlg and menu I should look for. Thanks!

Accepted Answer

Image Analyst
Image Analyst on 9 Jul 2013
Edited: Image Analyst on 9 Jul 2013
Have you considered using the menu() function?
button = menu('Choose a country', 'UK', 'Belgium', 'Italy', 'France' , 'Luxembourg')
Or a bunch of checkboxes or a listbox?
  1 Comment
Andrew Kreitzman
Andrew Kreitzman on 9 Jul 2013
I was under the impression that the menu function would only allow me to choose one country. I stumbled upon listbox last night, and I am trying to find a good example of its use because the mathworks example was a bit unclear to me.

Sign in to comment.

More Answers (1)

Sean de Wolski
Sean de Wolski on 9 Jul 2013
uicontrol('Style','listbox',...
'Units','normalized',...
'Position',[0.1 0.1 0.3 0.5],...
'String',{'Hello World','Happy Tuesday','One bourbon','One scotch','One beer'},...
'Max',3,... %Increase for multiselect
'Value',1,...
'Callback',[]);
The 'Max' property of a listbox controls multiselect.

Categories

Find more on Interactive Control and Callbacks 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!