MATLAB Answers

isempty is allways zero

3 views (last 30 days)
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.

  0 Comments

Sign in to comment.

Accepted Answer

Fangjun Jiang
Fangjun Jiang on 27 May 2020
zero and empty are different
isempty([])
isempty(0)
isempty('')

  4 Comments

Show 1 older comment
Fangjun Jiang
Fangjun Jiang on 27 May 2020
all(), any()
Nik Rocky
Nik Rocky on 27 May 2020
TP1 =
0 0 0
>> TP2 = [0 1 0]
TP2 =
0 1 0
>> any(TP1)
ans =
logical
0
>> any(TP2)
ans =
logical
1
Right?

Sign in to comment.

More Answers (0)

Tags