App Designer, expanding tree using a struct, plotting selected data, edit selected

5 ビュー (過去 30 日間)
Markus Knoch
Markus Knoch 2019 年 4 月 5 日
コメント済み: Jose 2022 年 8 月 31 日
Hello my name is markus, I´m an currently working as an intern with matlab. While writting my script I´ve stumpled upon the App Designer feature.
I think it has great potential and I would like to learn more about it. Sadly though, beeing a relatively new feature, the documentation, and tutorials are rare and most of them do not cover what I am interested in.
  1. I would like to acess data from a struct that I have created in my matlab script
  2. The struct should appear inside a tree, with all its subcells able to open on "childrens nobs"
  3. The selected data (from the struct), voltage, current and time data should then appear in a plot when they are selected in the tree and after hitting a button
  4. It would be nice to edit certain elements of the struct, which will be saved into the mat file (after hitting a button for example)
I´ve searched quite long for possible examples for such operations but I could not find any. I´m quite familiar with matlab code but the app designer style of obj based programming is very new to me. If anyone could help me solving some of those issues I would very much appreciate it.
I´m using 2018a.

回答 (3 件)

Markus Knoch
Markus Knoch 2019 年 4 月 5 日
I was able to also expand every node with the subsubstructs. Depending on the selected node, the corresponding data from the struct will be displayed at the plots.
myStruct = load('data_all.mat');
fNames1 = fieldnames(myStruct);
for i=1:numel(fieldnames(myStruct))
category(i)=uitreenode(app.Tree,'Text',string(fNames1(i)));
fNames2 = fieldnames(myStruct.(string(fNames1(i))));
for n=1:numel(fieldnames(myStruct.(string(fNames1(i)))))
uitreenode(category(i),'Text',string(fNames2(n)));
end
end
app.myStruct =myStruct;
function TreeSelectionChanged(app, event)
selectedNode = app.Tree.SelectedNodes;
x = app.myStruct.(selectedNode.Text).time;
y1 = app.myStruct.(selectedNode.Text).current;
y2 = app.myStruct.(selectedNode.Text).voltage;
plot(app.UIAxes,x,y2);
app.UIAxes.YLim = [0 22];
plot(app.UIAxes2,x,y1,'r');
app.UIAxes2.YLim = [-2 2];
  1 件のコメント
Jose
Jose 2022 年 8 月 31 日
Thank you for posting a solution, this was very helpful!

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


Markus Knoch
Markus Knoch 2019 年 4 月 5 日
Im currently working on it. I´ll share my progress.
myStruct = load('data_all.mat');
fNames = fieldnames(myStruct);
for j=1:numel(fieldnames(myStruct))
uitreenode(app.Tree,'Text',string(fNames(j)));
end
This creates the a tree with nodes named after the substruct fieldnames.

apple
apple 2019 年 7 月 5 日
Dear Markus Knoch,
I want to get the whole fields of one hdf5 data and set the data struct to app.Tree, I am not familiar with the nested struct data and the app.Tree . According to your methods, I tried but without success. Could you help me to clear this problem?
% Open the HDF5 File.
FN = 'ATL06_20190223232535_08780212_001_01.h5';
fid = H5F.open (FN, 'H5F_ACC_RDONLY', 'H5P_DEFAULT');
DataInfo = h5info(FN,'/'); % HDF5 data sturct
HDF5 data can be viewed by the following software:
https://www.giss.nasa.gov/tools/panoply/
Thank you very much!
HL

カテゴリ

Help Center および File ExchangeHDF5 についてさらに検索

タグ

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by