Selection of row from a matrix

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.....

 Respuesta aceptada

per isakson
per isakson el 20 de Abr. de 2013

0 votos

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 comentarios

raj singh
raj singh el 20 de Abr. de 2013
thanks for the solution,,,,,,,,,,,,,,,,,,,,,,,,
raj singh
raj singh el 20 de Abr. de 2013
this is run for given prob but not run for this
A= [1 1 1 2
1 2 3 4
1 2 4 5
3 4 3 3];
pls give me the suggestion
per isakson
per isakson el 20 de Abr. de 2013
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 el 20 de Abr. de 2013
:) yaa, its working, it was my fault. thanks

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Preguntada:

el 20 de Abr. de 2013

Community Treasure Hunt

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

Start Hunting!

Translated by