- Download the struct2Tree from file exchange.
- Extract the Zip to the same folder.
- Created a new mlapp in the extracted folder (struct2tree).
- Added a button to the 'Design View'
How to load a struct to an uitree in AppDesigner?
조회 수: 15 (최근 30일)
이전 댓글 표시
Hello,
I have an uitree in my AppDesigner GUI.
Is there a fast & convenient way to load a struct into my Tree.
My struct can vary in it's layers ("depth"). It can be:
S.L1.L2 or S.L1.L2.L3. etc...
I've found the following function on FileExchange:
struct2tree (https://www.mathworks.com/matlabcentral/fileexchange/42487-struct2tree).
But after I ran the code:
[m_tree , m_container] = struct2tree(my_struct);
I don't know how to "convert" (or maybe "display" is the more appropriate term) the data stored in m_tree and/or m_container to my uitree in the GUI itself.
I really hope struct2tree could help me. Since I don't know in advance the "depth" of my struct, I don't want start writing any recursive functions "extracting" all the layers from my struct and "building" uitree.
Thanks!!!
댓글 수: 0
답변 (1개)
prabhat kumar sharma
2024년 1월 17일
Hi Mark,
I have downloaded the struct2tree from the file exchange link you provided and tried creating the UITree.
Here are the steps I followed.
function ButtonPushed(app, event)
S = struct('Field1', 'Value1', 'Field2', struct('SubField1', 'SubValue1'));
h = gcf;
struct2tree(S);
end
5. Added a callback function to the button.
6. The UITree created and looks like below screenshot.
I hope it helps!
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Type Conversion에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!