How to check if an array is empty without using any built in functions
조회 수: 60 (최근 30일)
이전 댓글 표시
x = [];
x == [] , gives 0×0 empty logical array...
댓글 수: 0
채택된 답변
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
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
2021년 9월 4일
x=[];
[R,C]=size(x)
if R==0 & C==0
disp('Empty')
else
disp('Contains STH')
end
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!