junk, index and unique on a matrix (how to keep matrix format)
Using this method on a 8x8 matrix: >> [junk,index] = unique(data,'first'); %# Capture the index, ignore junk >> data(sort(index)) %# Index data with the sorted index Outputs the format in 64x1 format (if no repeats are found) or nx1 if some repeats are found. My question is how do I keep the matrix format without the sorting? i need it to check unique(rows) for duplicates not unique cells. And to delete the duplicate rows but keep the format (dont arrange/sort). If you want unique rows, while keeping original order, try this: [M,ind] = unique(data, 'rows', 'first'); [~,ind] = sort(ind); M = M