isempty is allways zero

조회 수: 4 (최근 30일)
Nik Rocky
Nik Rocky 2020년 5월 27일
댓글: Walter Roberson 2020년 5월 27일
Hello,
im using isempty:
TP =
0 0 0
>> isempty(TP)
ans =
logical
0
>> TP(3) = 1
TP =
0 0 1
>> isempty(TP)
ans =
logical
0
Why is locical answer still zero? What can I do? I need to check multiple arrays for empty or not in if-else blocks.

채택된 답변

Fangjun Jiang
Fangjun Jiang 2020년 5월 27일
zero and empty are different
isempty([])
isempty(0)
isempty('')
  댓글 수: 4
Nik Rocky
Nik Rocky 2020년 5월 27일
TP1 =
0 0 0
>> TP2 = [0 1 0]
TP2 =
0 1 0
>> any(TP1)
ans =
logical
0
>> any(TP2)
ans =
logical
1
Right?
Walter Roberson
Walter Roberson 2020년 5월 27일
Yes.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by