필터 지우기
필터 지우기

Selection of row from a matrix

조회 수: 1 (최근 30일)
raj singh
raj singh 2013년 4월 20일
i have a matrix,and i want remove that row in which numbers repeated
A= [3 5 5
6 9 1
7 5 7
2 4 6];
Ans: A=[6 9 1;2 4 6]
i used "for loop" for this problem, i want to ask there is any direct command to find the Ans. pls give me the suggestion.....

채택된 답변

per isakson
per isakson 2013년 4월 20일
Post the question at Cody:). It's a little exercise with logicl indexing.
>> A( any( diff( sort( A, 2 ), 1, 2 ) == 0, 2 ), : ) = []
A =
6 9 1
2 4 6
>>
  댓글 수: 4
per isakson
per isakson 2013년 4월 20일
Works here
A= [1 1 1 2
1 2 3 4
1 2 4 5
3 4 3 3];
A( any( diff( sort( A, 2 ), 1, 2 ) == 0, 2 ), : ) = []
A =
1 2 3 4
1 2 4 5
>>
raj singh
raj singh 2013년 4월 20일
:) yaa, its working, it was my fault. thanks

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

추가 답변 (0개)

카테고리

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