z = [-4 + 5i; 4.5 - 6i]; z = cplxsort (z) % Default tolerance should fail {Undefined function or variable 'cplxsort'.} tmp=cplxpair(z) {Error using cplxpair (line 78) Complex numbers can't be paired.} tmp=cplxpair(z,.15) {Error using cplxpair (line 78) Complex numbers can't be paired.} tmp=cplxpair(z,.18) {Error using cplxpair (line 78) Complex numbers can't be paired.} % check if tol is absolute with respect to abs() z=[-4+1.16i;-4-1.00i] z = -4.0000 + 1.1600i -4.0000 - 1.0000i tmp=cplxpair(z,.15) tmp = -4.0000 - 1.1600i -4.0000 + 1.1600i tmp=cplxpair(z,.18) tmp = -4.0000 - 1.1600i -4.0000 + 1.1600i abs(z) ans = 4.1648 4.1231 ans(1)-ans(2) ans = 0.0417 tmp=cplxpair(z,.04) tmp = -4.0000 - 1.1600i -4.0000 + 1.1600i tmp=cplxpair(z,.03) {Error using cplxpair (line 100) Complex numbers can't be paired.} %so with an abs() difference of 0.0417 a tol of 0.04 works but 0.03 errors % %now check if real part needs to be same sign z=[2+2i;1+i;2-2i;1-i]; tmp=cplxpair(z,eps) tmp = 1.0000 - 1.0000i 1.0000 + 1.0000i 2.0000 - 2.0000i 2.0000 + 2.0000i %note, sorted by smallest to biggest abs() z=[-2+2i;1+i;2-2i;1-i]; z z = -2.0000 + 2.0000i 1.0000 + 1.0000i 2.0000 - 2.0000i 1.0000 - 1.0000i tmp=cplxpair(z,eps) {Error using cplxpair (line 78) Complex numbers can't be paired.} diary off