cplxpair
年代ort complex numbers into complex conjugate pairs
年代yntax
B = cplxpair(A)
B = cplxpair(A,tol)
B = cplxpair(A,[],dim)
B = cplxpair(A,tol,dim)
Description
B = cplxpair(A)
sorts the elements along different dimensions of a complex array, grouping together complex conjugate pairs.
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 of100*eps
relative toabs(A(i))
determines which numbers are real and which elements are paired complex conjugates.
IfA
is a vector,cplxpair (A)
returnsA
with complex conjugate pairs grouped together.
IfA
is a matrix,cplxpair (A)
returnsA
with its columns sorted and complex conjugates paired.
IfA
is a multidimensional array,cplxpair (A)
treats the values along the first non-singleton dimension as vectors, returning an array of sorted elements.
B = cplxpair(A,tol)
overrides the default tolerance.
B = cplxpair(A,[],dim)
sortsA
along the dimension specified by scalar dim.
B = cplxpair(A,tol,dim)
sortsA
along the specified dimension and overrides the default tolerance.
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.