(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 CenterFile Exchange에서 Whos에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by