필터 지우기
필터 지우기

how to remove repeating rows from a matrix?

조회 수: 3 (최근 30일)
Zhang
Zhang 2011년 10월 12일
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
Florin Neacsu
Florin Neacsu 2011년 10월 12일
Hi,
Are your repeating lines always one after another? If so, you could use diff and look for [0 0].
Zhang
Zhang 2011년 10월 13일
No, they are not always one after another.thx

댓글을 달려면 로그인하십시오.

답변 (2개)

Andrei Bobrov
Andrei Bobrov 2011년 10월 12일
unique(A,'rows')
  댓글 수: 1
Zhang
Zhang 2011년 10월 13일
Thx, Andrei, yes, it is more simple, but still out of memory in my real case

댓글을 달려면 로그인하십시오.


Steven
Steven 2011년 10월 12일
Or even simpler for quick remove :
A(2,:)=[]
will give you B.

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by