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일

0 개 추천

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

댓글 수: 4

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 2020년 5월 27일
all(), any()
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개)

카테고리

도움말 센터File Exchange에서 Data Type Identification에 대해 자세히 알아보기

태그

질문:

2020년 5월 27일

댓글:

2020년 5월 27일

Community Treasure Hunt

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

Start Hunting!

Translated by