Remove repeated row in a matrix (specially zero's repeated row)

a =
1 4 6
0 0 0
6 7 3
0 0 0
3 1 2
0 0 0
0 0 0
Remove the repeated zero row.
I want this output
b=
1 4 6
0 0 0
6 7 3
3 1 2

댓글 수: 1

Anusha
Anusha 2013년 11월 5일
편집: Anusha 2013년 11월 5일
ADD part
a=
[1 4 6
0 0 0
6 7 3
0 0 0
3 1 2
0 0 0
0 0 0
1 0 0]
b=
1 4 6
0 0 0
6 7 3
3 1 2
1 0 0

답변 (1개)

Azzi Abdelmalek
Azzi Abdelmalek 2013년 11월 4일
편집: Azzi Abdelmalek 2013년 11월 5일
EDIT
a = [1 4 6
0 0 0
6 7 3
0 0 0
3 1 2
0 0 0
0 0 0]
idx=find(~any(a,2))
a(idx(2:end),:)=[]

댓글 수: 4

a=
[1 4 6
0 0 0
6 7 3
0 0 0
3 1 2
0 0 0
0 0 0
1 0 0]
if the matrix 1 0 0 row is in matrix means its also deleted in that code.. But it also include the output matrix
only 3 columns have zero means that repeated row only deleted
This is not clear
Please see ADD part
Ok, try this
idx=find(~any(a,2))
a(idx(2:end),:)=[]

이 질문은 마감되었습니다.

질문:

2013년 11월 4일

마감:

2021년 8월 20일

Community Treasure Hunt

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

Start Hunting!

Translated by