How to set ItemsData using external file (App Designer)?
15 views (last 30 days)
Show older comments
The purpose of my app is to create a UI which allows the user to select data they want to graph through a drop-down menu and adjust the graph to their liking through a series of edit fields. However, I am currently having trouble setting the ItemsData of my drop-down menu to the array variable from an external .mat file. Some of the difficulty stems from this being a multiwindowed app (based heavily on this tutorial). I am currently able to load the .mat file, but I can't figure out how to pass the array data to the popup window class and set it as an ItemData for the drop-down window. Attached are .txt files for both the main window and the popup window.
I greatly appreciate any suggestions on how to solve this.
5 Comments
Kevin Chng
on 20 Oct 2018
Hi gage benham, refer to my answer for it.
I recommend you modify your title so that it is not so confusing if people search for relevant solution.
Answers (1)
Kevin Chng
on 20 Oct 2018
Hi gage benham,
1st Step :
load your mat file. Make all the variable display in your drop menu automatically.
filename = whos(matfile('aaa.mat'));
w=load('aaa.mat')
for i =1:1:numel(filename)
A(i) = cellstr(filename(i).name);
app.var(i) = w.(A{i})
end
app.DropDown.Items = cellstr(A);
in first step, you are assignig all value of variable into app.var. You might need to expand the dimension of app.var(i) if needed
2nd Step :
In your call back function for plot
for i=1:1:numel(filename)
if strcmp(app.DropDown.Value,filename(i).name)
plot(var(i))
end
endTherefore, i gues now your apps is more dynamically even you have more variable in your mat.file.
0 Comments
See Also
Categories
Find more on Data Type Identification 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!