App Designer - How to generate dropdown lists using a cell array in the workspace
16 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Carlos Acasuso
il 17 Feb 2021
Commentato: Mario Malic
il 17 Feb 2021
Hello,
I am quite beginner with Matlab overall, and just started also using App Designer. I am trying to achieve something quite simple:
Being able to input as the items list in a list box a cell array that already exists in my workspace.
I have already brought the cell array into App Designer by using the following code:
function startupFcn(app, Specs_FARB_FW43_List)
Specs_FARB_FW43_List = evalin('base','Specs_FARB_FW43_List'); % varName is in MATLAB base workspace
end
and also stating it as a 'property', what should allow me to access it from other functions within this app.
properties (Access = private)
Specs_FARB_FW43_List % FARB Options List
end
My question is then, since the code where the list is stated is shaded, can't be modified, and the only way to specify the list's elements is in the 'Inspector' tab, I can't find a way to make this work.
Thanks in advance for your help.
Carlos
0 Commenti
Risposta accettata
Mario Malic
il 17 Feb 2021
Hi Carlos,
It's not possible to change the code in grey area. You can leave the default component values and change them in the startupFcn. I would highly advise you to not use evalin, as everyone else would in this forum. You are probably running your app from the script, or function - place your code in or call the functions in App Designer directly. I think you can also run scripts in App Designer (I have never tried it), you will not see the variables unless you're in debugging mode, which may cause issues in debugging the app later, asking yourself, where does this variable come from, etc.
function startupFcn(app)
% calling the function from the .m file
Specs_FARB_FW43_List = myfun1();
app.ListFarb.Items = Specs_FARB_FW43_List;
end
You can also create a "helper function"
methods
function app.results = myfun2()
% some code
% - results can be structure type and you can place all your variables of interest in it
% - set the output of the function to be the property so you can access it from anywhere
end
end
2 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Develop Apps Using App Designer in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!