Creating 2 dynamic and dependent dropdown menus in App-Designer

14 次查看(过去 30 天)
Hi all.
I have two dropdowns 'ddA' and 'ddB' where ddA is a list of files from a folder and ddB is a list of variable names from the files.
I can populate both easily but don't know how to make the variables in ddB change if a different folder is selected in ddA. The files, are all txt files but can have different dimensions and different variable names. I am storing each txt file as a table, all in their own separate cell in a cell array.
Will a valueChanged call back work for this or will I have to use some form of 'if' statement?
I hope to have a plot that can update dynamically with user input. Where a change in file will update the the ddB to the variables in that file and plot col 1 vs the variable selected in ddB.

采纳的回答

Voss
Voss 2023-7-21
Yes, a ValueChangedFcn will work for this.
The ValueChangedFcn of ddA will read the variable names from the selected file and update ddB.Items with those variable names, probably also updating ddB.Value to ensure it is valid (or just resetting it to the first Item).
The ValueChangedFcn of ddB will update the plot.
You can have the ValueChangedFcn of ddA call the ValueChangedFcn of ddB, so that when a selection is made in ddA not only does ddB update but the plot also updates automatically.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 MATLAB 的更多信息

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by