Undefined function 'sum' for input arguments of type 'struct'.

When I want to find a mean of a matrix A of size 1 by 18, the MATLAB give an error:
Undefined function 'sum' for input arguments of type 'struct'. Error in mean (line 30) y = sum(x,dim)/size(x,dim);
How can I solve this problem? Thanks.

Respuestas (1)

Geoff Hayes
Geoff Hayes el 6 de Sept. de 2014
Editada: Geoff Hayes el 6 de Sept. de 2014
omid - the error message is telling you that the input to your sum function is a struct. Either one (or both) of x or dim is a struct. In the Command Window, type
class(x)
followed by
class(dim)
What is the result from each statement? Depending upon which one is the struct, you will have to modify the inputs accordingly.

2 comentarios

Hi Geoff,
I have the same error and entered class(x) which resulted in x being the struct. Afterwards, I entered class(dim) and got undefined function or variable 'dim'. More precisely, which input should I modify and how should it be modified? Why the command class(dim) did not work? Could you please help me in matter? My Matlab skills are, unfortunately, very limited. Could you, therefore, explain a simple matter what went wrong? I would be very thankful for any help and guidance. Kind regards, Massilon
Massilon - in the code provided by omid (see question), there was a variable called dim. If you have not defined this variable then you will get the error that you are observing.

Iniciar sesión para comentar.

Categorías

Más información sobre Performance and Memory en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 6 de Sept. de 2014

Comentada:

el 19 de Mayo de 2017

Community Treasure Hunt

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

Start Hunting!

Translated by