Obtaining a logic vector (?) from a logic array

A v
[0 0 0 0] |0|
[1 0 0 0] |1|
[1 1 0 1] -> |1|
[0 0 0 0] |0|
[0 1 1 0] |1|
What I am looking for: n'th element of column vector v is 1 if any member of n'th row of the array A, if else 0.

 Respuesta aceptada

A = [0 0 0 0;
1 0 0 0;
1 1 0 1;
0 0 0 0;
0 1 1 0];
v = any(A,2)
v = 5×1 logical array
0 1 1 0 1

Más respuestas (0)

Categorías

Más información sobre Creating and Concatenating Matrices en Centro de ayuda y File Exchange.

Productos

Versión

R2020a

Etiquetas

Preguntada:

el 24 de Oct. de 2021

Comentada:

el 24 de Oct. de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by