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

2 Ansichten (letzte 30 Tage)
Dibran Kodra
Dibran Kodra am 20 Okt. 2020
Kommentiert: Dibran Kodra am 27 Okt. 2020
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.

Antworten (1)

Sahithi Kanumarlapudi
Sahithi Kanumarlapudi am 22 Okt. 2020
Hi,
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 Kommentar
Dibran Kodra
Dibran Kodra am 27 Okt. 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)
disp('load(filename)')
else
try
load(filename);
app.Data = importdata(filename);
app.FilenameEditField.Value=filename; %Show the file name here
app.FilepathEditField.Value=filepath; %Show the file path
catch
errordlg(['There was a problem loading the .mat','file'],'Load Error!');
return;
end
end
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;
end
app.DropDown.Items = cell_array;
end
Thank you for your time. I hope I could explain my problem a little bit better.

Melden Sie sich an, um zu kommentieren.

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by