Code covered by the BSD License  

Highlights from
SORTLIND (v2.1)

3.66667

3.7 | 3 ratings Rate this file 4 Downloads (last 30 days) File Size: 2.52 KB File ID: #19443

SORTLIND (v2.1)

by Jos (10584)

 

03 Apr 2008 (Updated 03 Apr 2008)

sorts input and returns linear indices for parallel sorting

| Watch this File

File Information
Description

[Y,I] = SORTLIND(X, ...) behaves (almost) exactly the same as the standard matlab function SORT, except that it returns linear indices so that Y equals X(I) independent of the dimensions and size of X.
(Note that [Y,I] = sort(X,...) returns sub-indices in I.)

Version 2.1, april 2008

Acknowledgements

The author wishes to acknowledge the following in the creation of this submission:
matchsort

MATLAB release MATLAB 7 (R14)
Other requirements Should work on most ML versions even before R14
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (5)
03 Apr 2008 Garrett Euler

Very nice. This is exactly what I need :).

06 Apr 2008 aasim azooz

The program has a bug when I tried to sort ten random numbers, the program went to create three dimentional array I gave the following statments
x=rand(1,10)
xx=sortlind(x)
try them and see what happens

07 Apr 2008 Jos (the author)

Dear Aasim,

I could not replicate your bug. The commands "x = rand(1,10) ; xx = sortlind(x); "
nicely returns an ordered 1-by-10 matrix called xx. Moreover, when called like this, SORTLIND just passes everything to SORT and does nothing else! What does sort(x) give you? Jos

08 Apr 2008 Jos (the author)

hmmm, someone really liked my file ...

02 Jul 2010 Thomas

Perfect - I really like your file!

Thomas

Please login to add a comment or rating.
Updates
03 Apr 2008

fixed some spelling errors

Tag Activity for this File
Tag Applied By Date/Time
matrices Jos (10584) 22 Oct 2008 09:56:23
linear Jos (10584) 24 Oct 2008 15:40:24
sort Jos (10584) 24 Oct 2008 15:40:24
unique Jos (10584) 24 Oct 2008 15:40:24
matrix Jos (10584) 24 Oct 2008 15:40:24
indices Jos (10584) 24 Oct 2008 15:40:24
index Jos (10584) 24 Oct 2008 15:40:24
parallel Jos (10584) 24 Oct 2008 15:40:24

Contact us at files@mathworks.com