Filter löschen
Filter löschen

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

3 Ansichten (letzte 30 Tage)
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!

Akzeptierte Antwort

Image Analyst
Image Analyst am 9 Jul. 2013
Bearbeitet: Image Analyst am 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 Kommentar
Andrew Kreitzman
Andrew Kreitzman am 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.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Sean de Wolski
Sean de Wolski am 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.

Kategorien

Mehr zu Interactive Control and Callbacks finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by