'(heaviside(x)-heaviside(x-1))'*x.^2 means the string '(heaviside(x)-heaviside(x-1))' matrix-multiplied by the element-wise square of x.
Anything in quotes is a string, not symbolic.
Also, matlabFunction() returns a function handle, not a symbolic function.
syms x
(heaviside(x)-heaviside(x-1)) * a
would be a symbolic expression. You could matlabFunction() the result, I suppose.