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

조회 수: 2 (최근 30일)
Khaled Hamed
Khaled Hamed 2012년 7월 29일
>> all([])
ans =
1
>> any([])
ans =
0
  댓글 수: 2
Ryan
Ryan 2012년 7월 29일
It's written into the documentation as such, but no explanation is given.
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

댓글을 달려면 로그인하십시오.

채택된 답변

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 CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by