Clear Filters
Clear Filters

(App Designer) show the variables from another function, in a dropdown?

3 views (last 30 days)
I have loaded a file, and in a dropdown list I would like to have the variables from the loaded file, with which I can work and show graphics after selecting one of the variables(in the dropdown)?
My variables contain always values in a Matrix or array.

Answers (1)

Sahithi Kanumarlapudi
Sahithi Kanumarlapudi on 22 Oct 2020
If you know what the variables are, you could use the 'Items' property of uidropdown() function by assigning it to your variables.
The following link has several examples on how to create a drop down and how to assign items, values to the dropdown list
Hope this helps!
  1 Comment
Dibran Kodra
Dibran Kodra on 27 Oct 2020
Hello Kanumarlapudi,
thank you for your answer.
My problem is that I have to work with different files, which include different variables. I have created a load Button as followed
function LoadButtonPushed(app, event)
[filename,filepath]=uigetfile(['*.mat'],'Load File','MultiSelect','off');
if isequal(filename,0)
app.Data = importdata(filename);
app.FilenameEditField.Value=filename; %Show the file name here
app.FilepathEditField.Value=filepath; %Show the file path
errordlg(['There was a problem loading the .mat','file'],'Load Error!');
After I load the file, I would like to work with a specific variable(all variables contain different arrays), from which I will filter the data or find specific requests like peek and valley from the graph of the chosen data. And to do this I would like to have the option that the variables will be shown in a drop down where I can choose which one I like to work with.
For the DropDown I used this code, but with evalin both options 'base' or 'caller' doesnt get me the variables I need. And the loaded file and its content will not be shown at the base workspace.
function DropDownOpening(app, event)
vars = evalin('base','whos');
cell_array = cell(size(vars));
for i=1:length(vars)
cell_array{i} = vars(i).name;
app.DropDown.Items = cell_array;
Thank you for your time. I hope I could explain my problem a little bit better.

Sign in to comment.


Find more on Develop Apps Using App Designer in Help Center and File Exchange


Community Treasure Hunt

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

Start Hunting!