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.
답변 (1개)
Geoff Hayes
2014년 9월 6일
편집: Geoff Hayes
2014년 9월 6일
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
Massilon Toniolo da Silva
2017년 5월 19일
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
Geoff Hayes
2017년 5월 19일
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.
카테고리
도움말 센터 및 File Exchange에서 Performance and Memory에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!