How can I find the values in a struct array tree structure

5 次查看(过去 30 天)
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 个评论
Jan
Jan 2019-9-11
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
Adam Danz 2019-9-11
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.

请先登录,再进行评论。

回答(1 个)

Ram Kumar
Ram Kumar 2019-9-11
The coordinates are stored in a struct array, much like the link you have mentioned. I have attached 2 pictures, I hope it's a bit more about the problem statment.tree.png
Picture1.png

类别

Help CenterFile Exchange 中查找有关 Structures 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by