필터 지우기
필터 지우기

How to load a struct to an uitree in AppDesigner?

조회 수: 4 (최근 30일)
Mark Golberg
Mark Golberg 2021년 12월 15일
답변: prabhat kumar sharma 2024년 1월 17일
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!!!

답변 (1개)

prabhat kumar sharma
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.
  1. Download the struct2Tree from file exchange.
  2. Extract the Zip to the same folder.
  3. Created a new mlapp in the extracted folder (struct2tree).
  4. Added a button to the 'Design View'
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!

카테고리

Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by