If I understand the documentation for cplxpair correctly, if you pass in a matrix with 2 columns, the function should sort the pairs in each column (unless you pass the DIM argument to tell it to sort along the specified dimension).
I am seeing that the second column is filled in with values from the first column. Here is my test script:
z = exp (2i*pi*[4; 3; 5; 2; 6; 1; 0]/7);
y = [ -1-1i; -1+1i;-3; -2; 1; 2; 3];
[z,y]
cplxpair([z,y])
cplxpair([z,y]) - [z,y]
I get:
>> z = exp (2i*pi*[4; 3; 5; 2; 6; 1; 0]/7);
>> y = [ -1-1i; -1+1i;-3; -2; 1; 2; 3];
>> [z,y]
ans =
-0.90097 - 0.43388i -1.00000 - 1.00000i
-0.90097 + 0.43388i -1.00000 + 1.00000i
-0.22252 - 0.97493i -3.00000 + 0.00000i
-0.22252 + 0.97493i -2.00000 + 0.00000i
0.62349 - 0.78183i 1.00000 + 0.00000i
0.62349 + 0.78183i 2.00000 + 0.00000i
1.00000 + 0.00000i 3.00000 + 0.00000i
>> cplxpair([z,y])
ans =
-0.90097 - 0.43388i -0.22252 - 0.97493i
-0.90097 + 0.43388i -0.22252 + 0.97493i
-0.22252 - 0.97493i -0.90097 - 0.43388i
-0.22252 + 0.97493i -0.90097 + 0.43388i
0.62349 - 0.78183i 0.62349 - 0.78183i
0.62349 + 0.78183i 0.62349 + 0.78183i
1.00000 + 0.00000i 1.00000 + 0.00000i
>> cplxpair([z,y]) - [z,y]
ans =
0.00000 + 0.00000i 0.77748 + 0.02507i
0.00000 + 0.00000i 0.77748 - 0.02507i
0.00000 + 0.00000i 2.09903 - 0.43388i
0.00000 + 0.00000i 1.09903 + 0.43388i
0.00000 + 0.00000i -0.37651 - 0.78183i
0.00000 + 0.00000i -1.37651 + 0.78183i
0.00000 + 0.00000i -2.00000 + 0.00000i
>>