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

94 次查看(过去 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
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