Code covered by the BSD License  

Highlights from
unique_no_sort_rows

3.0

3.0 | 1 rating Rate this file 2 Downloads (last 30 days) File Size: 1.32 KB File ID: #25187

unique_no_sort_rows

by Michael Petralia

 

31 Aug 2009 (Updated 31 Aug 2009)

find unique rows of a matrix without resorting the rows

| Watch this File

File Information
Description

Similar unique_no_sort in functionality, but adds the ability to find unique rows.

MATLAB release MATLAB 7.8 (R2009a)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (3)
31 Aug 2009 us

does not work on matrices M x N with N > 2,
since your statement
     B = unsorted(:,2:3);
should read
     B = unsorted(:,2:end);

us

31 Aug 2009 Michael Petralia

fixed this. file should now work with M x N matrices, N>2

02 Sep 2009 Johnson Wong

Must simpler would be:

[unique_sorted,i,j] = unique(A,'rows','first');
B = A(sort(i),:);

Please login to add a comment or rating.
Updates
31 Aug 2009

modified the output of the code to not include a column of indices.

31 Aug 2009

made function extend to MxN matrices with N>2

31 Aug 2009

uploaded correct file

Tag Activity for this File
Tag Applied By Date/Time
cell array Michael Petralia 31 Aug 2009 15:01:09
unique Michael Petralia 31 Aug 2009 15:01:10
matrix Michael Petralia 31 Aug 2009 15:01:10
matrices Michael Petralia 31 Aug 2009 15:01:10
unsorted Michael Petralia 31 Aug 2009 15:01:10
vector Michael Petralia 31 Aug 2009 15:01:10
rows Michael Petralia 31 Aug 2009 15:01:10

Contact us at files@mathworks.com