Search All of the Math Forum:

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

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: finding index of any element in a matrix
Replies: 6   Last Post: Jun 24, 2013 2:07 PM

 Messages: [ Previous | Next ]
 asif khan Posts: 16 Registered: 6/24/13
Re: finding index of any element in a matrix
Posted: Jun 24, 2013 2:07 PM

On Monday, June 24, 2013 4:03:41 PM UTC+5:30, Nasser M. Abbasi wrote:
> On 6/24/2013 5:13 AM, asif khan wrote:
>
>
>

> >
>
> > eg,R = rand(3,3)
>
> >
>
> > R =
>
> >
>
> > 0.4820 0.2262 0.2518
>
> > 0.1206 0.3846 0.2904
>
> > 0.5895 0.5830 0.6171
>
> >
>
> > I = find(R==0.6171)
>
> >
>
> > I =
>
> >
>
> > Empty matrix: 0-by-1
>
> > that is the problem... is there any precision problem???
>
> >
>
>
>
> Yes. You should never really use .EQ. with floating points.
>
>
>
> In addition, what you see on the screen is not the full number
>
> any way.
>
>
>
> EDU>> format short
>
> EDU>> R=rand(2)
>
> 0.8491 0.6787
>
> 0.9340 0.7577
>
>
>
> EDU>> find(R==0.7577)
>
> Empty matrix: 0-by-1
>
>
>
> Error using format
>
> EDU>> R
>
> 0.849129305868777 0.678735154857773
>
> 0.933993247757551 0.757740130578333
>
>
>
> To do an .EQ. on floating point (or any comparison, < or > etc..)
>
> you should use the abs/epsilon method. This is discussed in
>
> many places.
>
>
>
> --Nasser

i got the idea..

Date Subject Author
6/24/13 asif khan
6/24/13 Nasser Abbasi
6/24/13 asif khan
6/24/13 Nasser Abbasi
6/24/13 asif khan
6/24/13 Nasser Abbasi
6/24/13 asif khan