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

 채택된 답변

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

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개)

x=[];
[R,C]=size(x)
if R==0 & C==0
disp('Empty')
else
disp('Contains STH')
end

카테고리

도움말 센터File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

태그

질문:

2021년 9월 4일

댓글:

2021년 9월 4일

Community Treasure Hunt

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

Start Hunting!

Translated by