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.

 採用された回答

the cyclist
the cyclist 2021 年 10 月 24 日

0 投票

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

1 件のコメント

Mert Emrem
Mert Emrem 2021 年 10 月 24 日
Works like a charm, thanks!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeCreating and Concatenating Matrices についてさらに検索

製品

リリース

R2020a

質問済み:

2021 年 10 月 24 日

コメント済み:

2021 年 10 月 24 日

Community Treasure Hunt

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

Start Hunting!

Translated by