Obtaining a logic vector (?) from a logic array

1 Ansicht (letzte 30 Tage)
Mert Emrem
Mert Emrem am 24 Okt. 2021
Kommentiert: Mert Emrem am 24 Okt. 2021
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.

Akzeptierte Antwort

the cyclist
the cyclist am 24 Okt. 2021
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

Weitere Antworten (0)

Kategorien

Mehr zu Matrices and Arrays finden Sie in Help Center und File Exchange

Produkte


Version

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by