3.0

3.0 | 1 rating Rate this file 12 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)

Code covered by BSD License  

find unique rows of a matrix without resorting the rows

Download Now | 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)
Zip File Content  
Other Files license.txt,
unique_no_sort_rows.m
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
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com