how to remove repeating rows from a matrix?

1 Ansicht (letzte 30 Tage)
Zhang
Zhang am 12 Okt. 2011
I know "union" can be used to achieve this, for example, there is an A,
A =
1 2
1 2
1 3
B=union(a,a,'rows')
B =
1 2
1 3
but if A is big(In my case, A is a 20,000*30 matrix), it will be out of memory.
??? Out of memory. Type HELP MEMORY for your options.
ARE there simple ways to delete repeating arrows in a matrix? THX!
  2 Kommentare
Florin Neacsu
Florin Neacsu am 12 Okt. 2011
Hi,
Are your repeating lines always one after another? If so, you could use diff and look for [0 0].
Zhang
Zhang am 13 Okt. 2011
No, they are not always one after another.thx

Melden Sie sich an, um zu kommentieren.

Antworten (2)

Andrei Bobrov
Andrei Bobrov am 12 Okt. 2011
unique(A,'rows')
  1 Kommentar
Zhang
Zhang am 13 Okt. 2011
Thx, Andrei, yes, it is more simple, but still out of memory in my real case

Melden Sie sich an, um zu kommentieren.


Steven
Steven am 12 Okt. 2011
Or even simpler for quick remove :
A(2,:)=[]
will give you B.

Kategorien

Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by