From: Jan Simon on
Dear Keyne!

> Is there an easy way to remove nearly duplicate entries from a vector.

Have you tried Bruno's ISMEMBERF:
http://www.mathworks.com/matlabcentral/fileexchange/23294
I'm not sure if it works with complex numbers directly, but at least you can compare the real and imaginary part separately.

Good luck, Jan
From: Rune Allnor on
On 2 Mar, 10:30, "Keyne Dirks" <keynedi...(a)hotmail.com> wrote:
> Is there an easy way to remove nearly duplicate entries from a vector.
>
> Lets say I have a vector 'b' with four complex numbers:
>
> b =
> -0.940695022020893 - 0.338266306091317i
> -0.940695022020893 + 0.338266306091317i
> -0.941324562670116 - 0.338492683806694i
> -0.941324562670116 + 0.338492683806694i
>
> As you can see the 1st and 3rd numbers are nearly the same and the 2nd and 4th are also almost the same.  

No, they aren't. They are complex conjugates of each other.
Saying that two complex conjugate numbers are "the same"
makes as much sense as saying that 1 equals -1.

Rune
From: Jan Simon on
Dear Rune!

> > b =
> > -0.940695022020893 - 0.338266306091317i
> > -0.940695022020893 + 0.338266306091317i
> > -0.941324562670116 - 0.338492683806694i
> > -0.941324562670116 + 0.338492683806694i
> > As you can see the 1st and 3rd numbers are nearly the same and the 2nd and 4th are also almost the same.  
>
> No, they aren't. They are complex conjugates of each other.
> Saying that two complex conjugate numbers are "the same"
> makes as much sense as saying that 1 equals -1.

1st: -0.940695022020893 - 0.338266306091317i
3rd: -0.941324562670116 - 0.338492683806694i

2nd: -0.940695022020893 + 0.338266306091317i
4th: -0.941324562670116 + 0.338492683806694i

I agree, that these numbers are "nearly the same" and not complex conjugates of each other.

Kind regards, Jan
From: Rune Allnor on
On 2 Mar, 11:31, Rune Allnor <all...(a)tele.ntnu.no> wrote:
> On 2 Mar, 10:30, "Keyne Dirks" <keynedi...(a)hotmail.com> wrote:
>
> > Is there an easy way to remove nearly duplicate entries from a vector.
>
> > Lets say I have a vector 'b' with four complex numbers:
>
> > b =
> > -0.940695022020893 - 0.338266306091317i
> > -0.940695022020893 + 0.338266306091317i
> > -0.941324562670116 - 0.338492683806694i
> > -0.941324562670116 + 0.338492683806694i
>
> > As you can see the 1st and 3rd numbers are nearly the same and the 2nd and 4th are also almost the same.  
>
> No, they aren't. They are complex conjugates of each other.

Sorry; I missed that you compared between the two set of
conjugates.

What I would do:

1) Specify a limit L to what 'close' means
2) Sort the complex-valued numbers lexicographically
based on real and imaginary values
3) For each element in the sorted vector:
a) Find all the elements with higher real value
closer than L
b) Examine the imaginary values of the numbers on
this list
c) Flag the numbers, if any, that are closer to the
reference number than L

Due to the sorting step this would be at least O(NlogN)
complexity, but since you in the worst case must check
each element against all remaining elements, this is an
O(N^2) algorithm.

Rune