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: strange unique behaviour?
Replies: 4   Last Post: Jan 7, 2013 11:02 AM

 Messages: [ Previous | Next ]
 Curious Posts: 2,359 Registered: 12/6/04
Re: strange unique behaviour?
Posted: Jan 7, 2013 10:49 AM

"Andreas Lobinger" wrote in message <kceprq\$gol\$1@newscl01ah.mathworks.com>...
> Hello,
>
> i have some complex values (actually concentric hexagonal rings) in the struct n1.
> This should be (as this is constructed this way) : 19 unique values, which are later scattered to 57 (19 * 3) values. And unique (which is i guess internally a sort and some further processing) gives me:
>

> >> length(unique(n1.bases))
>
> ans =
>
> 20
>

> >> length(unique([real(n1.bases.') imag(n1.bases.')],'rows'))
>
> ans =
>
> 19
>
> This is done on a
> MATLAB Version 7.13.0.564 (R2011b)
> Operating System: Linux 3.0.4-43-default #1 SMP Wed Aug 31 09:30:44 UTC 2011 (a432f18) x86_64
>
> Any idea?

This probably has something to do with floating point arithmetic operations.

See question 5.1 of the MATLAB FAQ at:

<<http://matlab.wikia.com/wiki/FAQ>>

Specifically:

<<http://matlab.wikia.com/wiki/FAQ#Why_is_0.3_-_0.2_-_0.1_.28or_similar.29_not_equal_to_zero.3F>>

Date Subject Author
1/7/13 Andreas Lobinger
1/7/13 Steven Lord
1/7/13 Andreas Lobinger
1/7/13 Andreas Lobinger
1/7/13 Curious