How to check if an array is empty without using any built in functions

조회 수: 83 (최근 30일)
x = [];
x == [] , gives 0×0 empty logical array...

채택된 답변

Wan Ji
Wan Ji 2021년 9월 4일
편집: Wan Ji 2021년 9월 4일
Use isempty
x = [];
isempty(x)
Then the answer is
ans =
logical
1
  댓글 수: 1
Wan Ji
Wan Ji 2021년 9월 4일
Hi friend,
What do you mean by saying without using any built in functions?
Even x==[], the operator == is a built-in function.
So isempty(x), isqual(x,[]), or even numel(x)==0, length(x)==0
all the above can respond to your question.

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

추가 답변 (1개)

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2021년 9월 4일
x=[];
[R,C]=size(x)
if R==0 & C==0
disp('Empty')
else
disp('Contains STH')
end

카테고리

Help CenterFile Exchange에서 Multidimensional Arrays에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by