Multiple dropdown inputs to narrow down file options in App Designer

36 visualizaciones (últimos 30 días)
Good morning!
I have been using MATLAB App Designer for two months or so and right now, I am having some troubles using drop downs.
My goal is to have the user choosing 3 different values in 3 different drop downs. By choosing the first value in the first drop down, depending on the available options in the database, the values will adapt in the second drop down and then the user will pick a second value. After the first two values are chosen, the values in the third drop down will adjust again so that the user can choose the value needed. Once the three values are chosen, a different drop down menu otside of this panel will display the files that matches the values chosen by the user so that its data can be uploaded and the data plotted.
Would it be something possible?
Thank you!

Respuesta aceptada

Jon
Jon el 27 de Jul. de 2023
Editada: Jon el 27 de Jul. de 2023
I have attached a very simple example of how you might have the choice from one drop down menu change the possible choices from a second drop down. In this example initially both drop downs have three items. The first has Choice A, Choice B, Choice C, the second has Choice 1, Choice 2, Choice 3. When you select an item from the first list, the corresponding element is eliminated from the second list. So if you pick Choice B from the first list, the second drop down becomes Choice 1, Choice 3 (Choice 2 is eliminated). Anyhow this is just to illustrate the principle. You can modify with your specific logic.
The key idea is to use the value changed callback from the first drop down, to modify the Items property of the second,
% Code that executes after component creation
function startupFcn(app)
% Define initial drop down item lists
app.DropDown1.Items = {'Choice A','Choice B','Choice C'};
app.DropDown2.Items = {'Choice 1','Choice 2','Choice 3'};
end
% Value changed function: DropDown1
function DropDown1ValueChanged(app, event)
value = app.DropDown1.Value;
% Modify second drop down menu according to choice made here,
% specifically eliminate corresponding drop down item in the
% second list
idx = find(ismember(app.DropDown1.Items,value));
app.DropDown2.Items(idx) = [];
end
  4 comentarios
Margaux
Margaux el 27 de Jul. de 2023
Ok makes sense! I'll try to implement that. Thank you!
Jon
Jon el 27 de Jul. de 2023
Good, let me know if you have more questions once you get into the details

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Develop Apps Using App Designer en Help Center y File Exchange.

Productos


Versión

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by