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

2 ビュー (過去 30 日間)
Dibran Kodra
Dibran Kodra 2020 年 10 月 20 日
コメント済み: Dibran Kodra 2020 年 10 月 27 日
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.

回答 (1 件)

Sahithi Kanumarlapudi
Sahithi Kanumarlapudi 2020 年 10 月 22 日
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 件のコメント
Dibran Kodra
Dibran Kodra 2020 年 10 月 27 日
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.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeDevelop Apps Using App Designer についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by