The problem is that you allocated y
as a numeric (floating-point) array, not a symbolic one. a
is numeric, but when you multiply it by x
the result becomes symbolic. Because x
is a symbolic variable rather than a symbolic value, Matlab cannot perform the automatic cast back to double precision. You can allocate y
like this:
y = sym(zeros(1,3));