# MATLAB: Creating a Piecewise Symbolic function

createfunctionpiecewisesymbolic

hello!
I need help creating a piecewise function out of 2 symbolic functions. I have:
a = poly2sym(polyfun); %Convert to symbolic
b = poly2sym(polyfun1); %Convert to symbolic
Now I want to create a function f, that is the piecewise composition of a and b. I can use the heavisde function for regular numeric functions like this:
j = '(heaviside(x)-heaviside(x-1))'*x.^2;
But the above is a numeric expression. If I try to make mine numeric by doing:
j = '(heaviside(x)-heaviside(x-1))'*matlabFunction(a)
It returns an error about using "mtimes". A and b are both symbolic, and I need j to be pieciewise and also symbolic. Any ideas?
syms x(heaviside(x)-heaviside(x-1)) * a