Creating Uicontrol drop down menus with varied selections

3 visualizzazioni (ultimi 30 giorni)
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 Commento
Joseph Mazzella
Joseph Mazzella il 27 Nov 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.

Accedi per commentare.

Risposta accettata

Cris LaPierre
Cris LaPierre il 28 Nov 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 Commenti
Cris LaPierre
Cris LaPierre il 28 Nov 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 il 28 Nov 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.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su App Building in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by