Borrar filtros
Borrar filtros

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

3 visualizaciones (últimos 30 días)
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!

Respuesta aceptada

Image Analyst
Image Analyst el 9 de Jul. de 2013
Editada: Image Analyst el 9 de Jul. de 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 comentario
Andrew Kreitzman
Andrew Kreitzman el 9 de Jul. de 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.

Iniciar sesión para comentar.

Más respuestas (1)

Sean de Wolski
Sean de Wolski el 9 de Jul. de 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.

Categorías

Más información sobre Interactive Control and Callbacks en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by