Creating Uicontrol drop down menus with varied selections

4 visualizaciones (últimos 30 días)
How can you create a uicontrol drop down menu's that are dependent on the selection of the previous menu. Basically I want to be able to have a list of brands then select one and have a list of models and from the brand selection it will only show the models associated to that brand. I am thinking using if statements and a callback but am not sure how to put it all together. Any help would be great thank you.
  1 comentario
Joseph Mazzella
Joseph Mazzella el 27 de Nov. de 2018
If the user selects a item from the first popupmenu only I want only certain items of the string of the second popupmenu to show.

Iniciar sesión para comentar.

Respuesta aceptada

Cris LaPierre
Cris LaPierre el 28 de Nov. de 2018
Are you doing this programmatically, in App Designer or GUIDE?
You can't hide items in a dropdown menu list. You can hide it until a selection is made in another dropdown list and populate its items based on what was selected.
You would use a callback function that will execute when the value is changed.
If I assume App Designer:
% Value changed function: DropDown
function DropDownValueChanged(app, event)
value = app.DropDown.Value;
app.DropDown2.Visible = 1;
switch value
case 'Option 1'
app.DropDown2.Items = {'A','B','C'};
case 'Option 2'
app.DropDown2.Items = {'D','E','F'};
case 'Option 3'
app.DropDown2.Items = {'G','H','I'};
end
end
  11 comentarios
Cris LaPierre
Cris LaPierre el 28 de Nov. de 2018
Not in a GUI. Code execution all occurs in functions.
Mat files load variables to the workspace, not to a variable. If you want to capture them in the handles structure, you'd have to know what each of those variable names is going to be and manually assign them to the handles structure.
load('Toyota_Dual_VVT_i_1GR_FE_Engine_Specs.mat');
handles.data.var1 = var1;
handles.data.var2 = var2;
...
I'm curious. What are we designing this for? If this is a class project, I'm tempted to step back and let you figure some things out on your own.
Joseph Mazzella
Joseph Mazzella el 28 de Nov. de 2018
It is a personal project that I opted to take up on that will then be used as a class project. I appreciate the help I am just new to the GUI controls of MATLAB.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre App Building en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by