Code covered by the BSD License  

Highlights from
CSORT

Be the first to rate this file! 5 Downloads (last 30 days) File Size: 1.84 KB File ID: #9552

CSORT

by Peter (PB) Bodin

 

08 Jan 2006 (Updated 11 Jan 2006)

Sorts complex arrays. Six different methods are available.

| Watch this File

File Information
Description

For vectors, CSORT(X) sorts the elements of X in ascending order.

For matrices, CSORT(X) sorts each column of X in ascending order.

The standard method is a lexical sort, first sort by real part,then by imaginary part.

Y = CSORT(X,METHOD,DIM,MODE)
has three optional parameters.

METHOD selects the method of the sort
   'lexi' lexical sort, sort first by REAL(X), then by IMAG(X)
   'angle' sort by phase angle, ANGLE(X)
   'abs' sort by magnitude, ABS(X)
   'real' sort by real part, REAL(X)
   'imag' sort by imaginary part, imag(X)
   'absangle' sort first by ABS(X), then ANGLE(X) (Matlab standard)

DIM selects a dimension along which to sort.

MODE selects the direction of the sort
   'ascend' results in ascending order
   'descend' results in descending order

The MODE option is not valid for lexical sorting.

The result is in Y which has the same shape and type as X

[Y,I] = CSORT(X,METHOD,DIM,MODE) also returns an index matrix I.

If X is a vector, then Y = X(I).
If X is an m-by-n matrix and DIM=1, then
    for j = 1:n, Y(:,j) = X(I(:,j),j); end

MATLAB release MATLAB 7.1.0 (R14SP3)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Please login to add a comment or rating.
Updates
09 Jan 2006

Corrected some typos in the description.

11 Jan 2006

Changed the summary

Tag Activity for this File
Tag Applied By Date/Time
matrices Peter (PB) Bodin 22 Oct 2008 08:11:40
complex sort Peter (PB) Bodin 22 Oct 2008 08:11:40
sort Peter (PB) Bodin 22 Oct 2008 08:11:40
csort Peter (PB) Bodin 22 Oct 2008 08:11:40

Contact us at files@mathworks.com