How to set ItemsData using external file (App Designer)?
16 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
Kevin Chng
2018 年 10 月 20 日
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.
回答 (1 件)
Kevin Chng
2018 年 10 月 20 日
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 件のコメント
参考
カテゴリ
Help Center および File Exchange で Data Type Identification についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!