Effacer les filtres
Effacer les filtres

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

3 vues (au cours des 30 derniers jours)
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!

Réponse acceptée

Image Analyst
Image Analyst le 9 Juil 2013
Modifié(e) : Image Analyst le 9 Juil 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 commentaire
Andrew Kreitzman
Andrew Kreitzman le 9 Juil 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.

Connectez-vous pour commenter.

Plus de réponses (1)

Sean de Wolski
Sean de Wolski le 9 Juil 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.

Catégories

En savoir plus sur Interactive Control and Callbacks dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by