MATLAB: Do I get an error “Integers can only be combined with integers of the same class, or scalar doubles” when evaluating arithmetic expression

classcombineddoubleserrorintegersMATLABscalar

I am trying to evaluate an arithmetic expression but receive an error with the following message: "Integers can only be combined with integers of the same class, or scalar doubles". What does this mean and how can I fix it?

Best Answer

This error message is likely the result of applying a binary operator (e.g., addition, subtraction) where one operand is an integer value and the other is either an integer value of a different class or a non-scalar double array. To avoid this error, convert any integer operands to type "double" before evaluating the expression. See the following link for information on how to do this: