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.
Creating Uicontrol drop down menus with varied selections
    4 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    Joseph Mazzella
 el 27 de Nov. de 2018
  
    
    
    
    
    Comentada: Joseph Mazzella
 el 28 de Nov. de 2018
            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. 
Respuesta aceptada
  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
    
      
 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.
Más respuestas (0)
Ver también
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

