Undefined function 'eq' for input arguments of type 'struct'

8 visualizaciones (últimos 30 días)
pamela sulis
pamela sulis el 27 de Oct. de 2015
Editada: pamela sulis el 28 de Oct. de 2015
Hi! I create this code in which s is a struct
if(s(1,1)==[])
i=i+1;
end
I have an error: 'Undefined function 'eq' for input arguments of type 'struct', I don't understand the error's meaning. Someone can help me, thanks
  2 comentarios
Stephen23
Stephen23 el 27 de Oct. de 2015
Do you want to test if the structure is empty?
If s is a structure, then s(1,1) will also be a structure, which clearly is not a number and so does not make sense to check if it equals something else.
pamela sulis
pamela sulis el 28 de Oct. de 2015
Editada: pamela sulis el 28 de Oct. de 2015
yes, i want to test if the structure is empty... I try if(isempty(s)) instead of if(s(1,1)==[]) and i solve my problem! Thanks

Iniciar sesión para comentar.

Respuesta aceptada

James Tursa
James Tursa el 27 de Oct. de 2015
Does this do what you want?
if( isempty(s) )
  3 comentarios
James Tursa
James Tursa el 27 de Oct. de 2015
Editada: James Tursa el 27 de Oct. de 2015
I know. It is for readability ... at least to my eyes. Could be as you surmise, because it looks more like C or Fortran, so my brain doesn't have to think as much in determining what is on the line.
pamela sulis
pamela sulis el 28 de Oct. de 2015
I use if( isempty(s) ) and i solve the problem! Thanks

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

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

Community Treasure Hunt

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

Start Hunting!

Translated by