Effacer les filtres
Effacer les filtres

How to load a struct to an uitree in AppDesigner?

4 vues (au cours des 30 derniers jours)
Mark Golberg
Mark Golberg le 15 Déc 2021
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!!!

Réponses (1)

prabhat kumar sharma
prabhat kumar sharma le 17 Jan 2024
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!

Catégories

En savoir plus sur Data Type Conversion dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by