Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Topic: find value in structure
Replies: 2   Last Post: Apr 3, 2013 7:29 AM

 Search Thread: Advanced Search

 Messages: [ Previous | Next ]
 Loren Shure Posts: 1,067 Registered: 12/7/04
Re: find value in structure
Posted: Apr 3, 2013 6:27 AM
 Plain Text Reply

"Stefan " <s.g.h.heinen@student.tue.nl> wrote in message
news:kjgp6n\$4uo\$1@newscl01ah.mathworks.com...
> Hey Yall,
>
> I want to find a value within a structure, i know I can find it with a for
> loop but that seems to be insufficient. Example:
>
> The structure is called tree with field c containing the coordinates of an
> edge and c varies in length depending on the length of the edge! Value is
> a double and the value to find.
>
> I cant figure out, how to do this with structfun
>
> structfun(@find, tree.c, value) or
> structfun(@x, find(value == x), tree.c) does not work
>
> Anyone a solution for my problem?
>
> Thanks in advance!
> Stefan
>
>

Be careful comparing floating point values. You probably want to look for a
value that has only a small difference from value - something like
find(abs(value-x) < tol) where tol depends on the magnitude of value
probably.

--
--Loren

http://blogs.mathworks.com/loren

Date Subject Author
4/3/13 Stefan
4/3/13 Loren Shure
4/3/13 kinor

© The Math Forum at NCTM 1994-2017. All Rights Reserved.