- Add a property to store Node handles.
- Add a 'containers.Map' object to populate the nodes and respective values.
- Create a tree node using the 'uitreenode' function and add it to the Node handles.
- Since the 'uitreenode' function expects a parent attribute. Incase, a parent child relationship is needed to be established in the tree, the appropriate parent node can be passed.
App designer tree nodes from excel file
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Fairly new to Matlab shout if I'm being dumb in the approach.
I am trying to generate a app that will self-populate a tree (parent and child nodes) from an excel file. I can generate the correct tree using a small for loop from an inputted excel file. However, the problem arises when trying to reference the populated nodes.
E.g. if you knew what the nodes were going to be called, you would create one and label it "Node1". The container browser then shows "app.Node1", which can then be refernced in code. Having the code self-populate the tree I am struggling to reference the new nodes. E.g. if a newly created node is called "CustomNode" I cannot refernce it with "app.CustomNode" despite it showing correctly in the tree when the program is running.
Hope that makes sense!
Thanks in advance for any and all help.
0 Kommentare
Antworten (1)
Rahul
am 8 Mai 2025
In order to read data from an excel file and populate a 'uitree' component in MATLAB App Designer, consider the following:
Here is some sample code:
data = readcell('Book1.xlsx');
% Initialize storage (use a containers.Map for easy name-based lookup)
app.NodeHandles = containers.Map();
node1 = uitreenode(app.Tree, 'Text', data{1});
app.NodeHandles(data{1}) = node1;
node2 = uitreenode(node1, 'Text', data{2});
app.NodeHandles(data{2}) = node2;
node3 = uitreenode(app.Tree, 'Text', data{3});
app.NodeHandles(data{3}) = node3;
node4 = uitreenode(node3, 'Text', data{4});
app.NodeHandles(data{4}) = node4;
The following MathWorks documentations can be referred:
'containers.Map': https://www.mathworks.com/help/matlab/ref/containers.map.html
Thanks.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Data Import from MATLAB finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!