MATLAB: What is meaning of this error : Undefined operator ‘*’ for input arguments of type ‘struct’

arguments of type 'struct' in matlab

what is meaning of this error : Undefined operator '*' for input arguments of type 'struct'

Best Answer

It means you tried to use the matrix multiply operator on a struct. E.g.,
>> a.x = 1:3
a =
x: [1 2 3]
>> b.y = (1:3)'
b =
y: [3x1 double]
>> a*b % <-- try to multiply two struct's
Undefined operator '*' for input arguments of type 'struct'.
>> a.x * b.y % <-- try to multiply the contents of two fields of struct's
ans =
14
So, trying to multiply the struct's themselves generates the error, while trying to multiply the contents of two fields of struct's that are compatible is OK.
Related Question