|
"Abdul Rauf Anwar" <raufanwar@gmail.com> wrote in message <he9cl2$rcn$1@fred.mathworks.com>...
> hi everyone
> i am having problem regarding find a specific value inside nested structure. problem is regarding tree formation in which one node can take another node as its child.
> and task is to traverse to final leaf.
> i have got my structure correct and after execution. if i type this on prompt
>
> >> node(11).right.right.left
>
> ans =
>
> 6
>
> >> node(11).right.right
>
> ans =
>
> left: 6
> right: [1x1 struct]
> freq: 0.3182
> isLeaf: 'false'
>
> is there someway that i get complete path for only doubles ( which is 6 in above example ) as node(11).right.right.left
> and it should not give path for 'non doubles' ( which is [1x1 struct] )
> thanks in anticipation
You need to write a function that loops through the fields of the struct and checks which ones are doubles, e.g.
isdouble=isa(node.left, 'double');
You must call this function recursively in order to descend through the tree and have this applied at all levels.
|