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.

 Respuesta aceptada

Fangjun Jiang
Fangjun Jiang el 27 de Mayo de 2020

0 votos

zero and empty are different
isempty([])
isempty(0)
isempty('')

4 comentarios

Nik Rocky
Nik Rocky el 27 de Mayo de 2020
Okay, and how can i detect a zero values?
For example:
TP =
0 0 0
>> ismember(TP,0)
ans =
1×3 logical array
1 1 1
>> TP(3) = 1
TP =
0 0 1
>> ismember(TP,0)
ans =
1×3 logical array
1 1 0
How can I do it for whole array and just get a value for all zeros 1 and for not all zeros 0?
Fangjun Jiang
Fangjun Jiang el 27 de Mayo de 2020
all(), any()
Nik Rocky
Nik Rocky el 27 de Mayo de 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 el 27 de Mayo de 2020
Yes.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Data Type Identification en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 27 de Mayo de 2020

Comentada:

el 27 de Mayo de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by