Check to find if a row has an element occuring more than once
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
altaf ahmed
el 12 de Mayo de 2019
Editada: madhan ravi
el 13 de Mayo de 2019
I need to find if a row has more than one occurence of 1s. I am expecting a response return like true or false. Sample row matrix is below:
0 0 1 1 0 0
0 comentarios
Respuesta aceptada
Stephan
el 12 de Mayo de 2019
Editada: Stephan
el 12 de Mayo de 2019
A = [0 0 1 1 0 0; 0 0 0 0 0 1; 1 1 0 0 0 1]
res = (sum(A==1,2)>1)
This works row-wise for more than 1 rows
4 comentarios
madhan ravi
el 13 de Mayo de 2019
Editada: madhan ravi
el 13 de Mayo de 2019
idx = a~=0;
a(idx) = a(idx) + 1;
Más respuestas (0)
Ver también
Categorías
Más información sobre Logical en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!