How can I find the values in a struct array tree structure
5 views (last 30 days)
Show older comments
I have a tree structure, each node of the tree structure is a struct array. For example, this the tree structure and each node is a strcut array with fields (name, X, Y, Z) and values. I need to find the distance between 'D1' to 'B' and similarly 'D2' to 'B' and 'D3' to 'B'.
Can you help me ? thanks in advance

2 Comments
Jan
on 11 Sep 2019
Please post some example code, which creates the "tree structure". The current description is too vague to post some code. E.g. struct do not have values, but only the fields of the structs do. I guess you are talking of a struct array, which has the fields 'name', 'X', 'Y' and 'Z'. But how is "parent" defined here? What is "the path from the node to the parent"?
Adam Danz
on 11 Sep 2019
That picture might help but I'm still lost.
"each node is a [structure] array with fields (name, X, Y, Z) and values."
Are you talking about variables that are from the class "struct" like this (link below)?
"I need to find the distance between 'D1' to 'B' and similarly 'D2' to 'B' and 'D3' to 'B'. "
Where are the coordinates / positions stored? We're still very much in the dark, here.
Answers (1)
See Also
Categories
Find more on Structures in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
