or operation on the columns of a matrix ?

23 visualizaciones (últimos 30 días)
Nora Khaled
Nora Khaled el 12 de Mayo de 2019
Comentada: Nora Khaled el 15 de Sept. de 2020
Hello!
I have matrix S that contains zeros and ones. and I want to convert it to a column vector contianing one in the ith position if there was at least one one in the ith row.
So I know that "or" operation does similar job but with two vectors. is there a way to use it with the columns of S ?

Respuesta aceptada

Image Analyst
Image Analyst el 12 de Mayo de 2019
Try
rowHasOnes = any(S, 2);
If not, then supply an example S and the expected result.
  3 comentarios
Sanchari Thakur
Sanchari Thakur el 15 de Sept. de 2020
what is the 'and' version of the 'any' function?
Nora Khaled
Nora Khaled el 15 de Sept. de 2020
all(A) or all(A, dim)

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Matrices and Arrays 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!

Translated by