cplxpair

Purpose

Sort complex numbers into complex conjugate pairs.

Synopsis

x = cplxpair(x)
x = cplxpair(x,tol)

Description

x = cplxpair(x) returns x with complex conjugate pairs grouped together. The conjugate pairs are ordered by increasing real part. Within a pair, the element with negative imaginary part comes first. The purely real values are returned following all the complex pairs.

The complex conjugate pairs are forced to be exact complex conjugates. A default tolerance of 100*eps relative to abs(x(i)) determines which numbers are real and which elements are paired complex conjugates.

x = cplxpair(x,tol) overrides the default tolerance.

Examples

Order into complex pairs five poles evenly spaced around the unit circle:

cplxpair(exp(2*pi*i*(0:4)/5)')
ans =
    -0.8090 - 0.5878i
    -0.8090 + 0.5878i
     0.3090 - 0.9511i
     0.3090 + 0.9511i
     1.0000 

Diagnostics

If there are an odd number of complex numbers, or if the complex numbers cannot be grouped into complex conjugate pairs within the tolerance, cplxpair generates the error message:

Complex numbers can't be paired.

(c) Copyright 1994 by The MathWorks, Inc.