Dear all; how to check if at least one array in a logical vector is true? for example: A=[0 0 0 1 0 0] and there is at least one ''1'' in this array.

10 ビュー (過去 30 日間)
farimah amn
farimah amn 2016 年 8 月 12 日
編集済み: Azzi Abdelmalek 2016 年 8 月 12 日
Dear all; how to check if at least one array in a logical vector is true? for example: A=[0 0 0 1 0 0] and there is at least one ''1'' in this array.

回答 (1 件)

Azzi Abdelmalek
Azzi Abdelmalek 2016 年 8 月 12 日
編集済み: Azzi Abdelmalek 2016 年 8 月 12 日
A=[0 0 0 1 0 0]
out=any(A)
To check if theye are all equal to 1 use all(A)

カテゴリ

Help Center および File ExchangeData Types についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by