How to check if an array is empty without using any built in functions
95 次查看(过去 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!