isempty is allways zero

1 Ansicht (letzte 30 Tage)
Nik Rocky
Nik Rocky am 27 Mai 2020
Kommentiert: Walter Roberson am 27 Mai 2020
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.

Akzeptierte Antwort

Fangjun Jiang
Fangjun Jiang am 27 Mai 2020
zero and empty are different
isempty([])
isempty(0)
isempty('')
  4 Kommentare
Nik Rocky
Nik Rocky am 27 Mai 2020
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 am 27 Mai 2020
Yes.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Argument Definitions finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by