I assume you meant x(t) = sin(pi*t) (not sin(pi*x)).
Let's rewrite: x(t) = sin(2 * pi / 2 * t). So x(t) has period T = 2 as shown on your plot But h(t) is a rectangular pulse of width 2. So for any value of t the integrand of the convolution integral
y(t) = int(x(tau)*h(t - tau),tau,-inf,inf)
is zero everwhere, except over one period of x(tau). But the integal of x(tau) over one period is zero, so the convolution integral is zero for any value of t.
For reasons I don't understand, Matlab doesn't like computing the integral symbolically:
h(t) = 2*(heaviside(t-1) - heaviside(t-3));
y(t) = int(x(tau)*h(t-tau),tau,-inf,inf)
But we can evaluate it numerically for some example cases
We can also go into the frequency domain to compute the Fourier tansform of the convolution and the take the inverse
y(t) = ifourier(fourier(h(t))*fourier(x(t)))
Also, be careful using heaviside() in the discrete domain. The default is heaviside(0) = 1/2, which is, at least almost always, not what you want for the unit step function in the discrete domain. You can change the default using sympref.