"Florent Kadrija" <florent.kadrija@gmail.com> wrote in message <jjii2k$ht1$1@newscl01ah.mathworks.com>...
> Hi,
>
> as I am new to matlab so I need your help. I want so sort, let say this vector of complex symbols according to their signs: for instance consider:
> a=0.4681 + 0.3268i
> 0.6969  0.6949i
> 0.6662  0.6710i
> 0.6428 + 0.6534i
> 0.5679  0.6836i
> 0.6971 + 0.7041i
> 0.5564  0.6839i
> 0.5863 + 0.6813i
> 0.5791  0.6611i
> 0.3268 + 0.6967i
> 0.6055 + 0.6077i
> 0.6975  0.5981i
> 0.6832 + 0.5515i
> 0.5244  0.7060i
> 0.7041  0.5799i
> 0.6681 + 0.7046i
> 0.6560  0.6955i
> 0.6029 + 0.5291i
>
> there are 4 possibilities:
> 1. a=b+jc
> 2. a=bjc
> 3. a=b+jc
> 4. a=bjc
>
> What I want is to sort all the complex symbols from vector a in the above given order. Can any body help me doing this???
>
> Ann after sorting in the given order the next step is to mapp these symbols in the given order, for instance:
>
> 1 0 2 0 1 2 0 3 3 1 1
>
> which means that all complex number are mapped according to:
>
> 1. a=b+jc > 0
> 2. a=bjc > 1
> 3. a=b+jc >2
> 4. a=bjc> 3
>
> Is this possible to do, and can anybody give me an Idea or help me how to do this...
>
> Thanks in advance,
> Flori
        
mapp = (imag(a)<0) + 2*(real(a)<0);
[~,p] = sort(mapp);
a_sorted = a(p);
Note: I have assumed here that you want no sorting other than by the signs in the real and imaginary parts. Also I assume that when either of these parts is zero, the corresponding sign is plus.
Roger Stafford
