2011-11-10 40 views
11

我想從矩陣中刪除重複的行。我讀How can I remove duplicates in an array but keep the same order?,但這不完全是我想要的。如何從矩陣中刪除重複的行

在溶液上方從矩陣中移除重複的值(細胞)(並返回一個向量),但我需要刪除重複並返回一個矩陣—相同的基質而不重複行。

實施例:

a = [1,2; 3,4; 5,6; 1,2; 7,8] 

a = 
    1  2 
    3  4 
    5  6 
    1  2 
    7  8 

%... 

ans = 
    1  2 
    3  4 
    5  6 
    7  8 

的順序並不重要。

+0

的唯一行,如果你也想保留行的原始順序,看看這個答案:http://stackoverflow.com/questions/7781749/junk-index-and-unique-on-a-matrix-how-to-keep-matrix-format/7782227#7782227 – Amro

回答