No BSD License  

Highlights from
sort2li

Be the first to rate this file! 3 Downloads (last 30 days) File Size: 2.28 KB File ID: #19421

sort2li

by Garrett Euler

 

01 Apr 2008 (Updated 03 Apr 2008)

Transforms permutation indices from sort to linear indices

| Watch this File

File Information
Description

This function transforms the indices output from sort into a matrix of linear indices so that parallel sorting is simplified. If no dimension argument is supplied, sort2li will operate on the first non-singleton dimension just like sort will do without a dimension argument.

Usage: li=sort2li(sort_indices)
       li=sort2li(sort_indices,dim)

Examples:
      
Sort a and then sort the elements of b exactly the same way.

  b=1./a;
  [c,i]=sort(a)
  d=b(sort2li(i))
  isequal(c,1./d)

MATLAB release MATLAB 7.5 (R2007b)
Other requirements Not tested on pre-7.
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
03 Apr 2008

Updated submat_noeval subfunction.

03 Apr 2008

Update documentation -> reshape wasn't needed.

Tag Activity for this File
Tag Applied By Date/Time
matrices Garrett Euler 22 Oct 2008 09:56:11
sort indices Garrett Euler 22 Oct 2008 09:56:11
transforms Garrett Euler 22 Oct 2008 09:56:11
permutation Garrett Euler 22 Oct 2008 09:56:11
incides Garrett Euler 22 Oct 2008 09:56:11
matrix manipulation Garrett Euler 22 Oct 2008 09:56:11

Contact us at files@mathworks.com