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

85 visualizaciones (últimos 30 días)
x = [];
x == [] , gives 0×0 empty logical array...

Respuesta aceptada

Wan Ji
Wan Ji el 4 de Sept. de 2021
Editada: Wan Ji el 4 de Sept. de 2021
Use isempty
x = [];
isempty(x)
Then the answer is
ans =
logical
1
  1 comentario
Wan Ji
Wan Ji el 4 de Sept. de 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.

Iniciar sesión para comentar.

Más respuestas (1)

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

Categorías

Más información sobre Multidimensional Arrays en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by