Any idea why all([]) is true while any([]) is false

6 ビュー (過去 30 日間)
Khaled Hamed
Khaled Hamed 2012 年 7 月 29 日
>> all([])
ans =
1
>> any([])
ans =
0
  1 件のコメント
Ryan
Ryan 2012 年 7 月 29 日
It's written into the documentation as such, but no explanation is given.

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

採用された回答

Daniel Shub
Daniel Shub 2012 年 7 月 29 日
This post by Loren lead to some comments that address the issue, especially the one by Matt Fig.

その他の回答 (1 件)

the cyclist
the cyclist 2012 年 7 月 29 日
I can't say I know definitively, but I expect that one reason is for consistency when taking the union of sets with the empty set. For example, one would want
all(union(true,[]))
to be true, and also
any(union(false,[]))
to be false. The definitions in your question make sense in that context.
  1 件のコメント
Khaled Hamed
Khaled Hamed 2012 年 7 月 29 日
I have just noticed the same with NaN! more confusing
>> all(nan)
ans =
1
>> any(nan)
ans =
0

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

カテゴリ

Help Center および File ExchangeRandom Number Generation についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by