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

88 vues (au cours des 30 derniers jours)
x = [];
x == [] , gives 0×0 empty logical array...

Réponse acceptée

Wan Ji
Wan Ji le 4 Sep 2021
Modifié(e) : Wan Ji le 4 Sep 2021
Use isempty
x = [];
isempty(x)
Then the answer is
ans =
logical
1
  1 commentaire
Wan Ji
Wan Ji le 4 Sep 2021
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.

Connectez-vous pour commenter.

Plus de réponses (1)

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

Catégories

En savoir plus sur Multidimensional Arrays dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by