MATLAB: Shade the encircled area

areaconvolutionfaqshade region between curves

Hi. Can anyone please tell me how to shade the encircled area(in red)?
The graph is as follows
And the code is as follows
tx1=-7:0.1:-1;
tx2=-1:0.1:0.5;
tx3=0.5:0.1:3;
tx4=3:0.1:7;
tx=[tx1 tx2 tx3 tx4];
x1=zeros(size(tx1));
x2=0.6.*ones(size(tx2));
x3=0.3.*ones(size(tx3));
x4=zeros(size(tx4));
x=[x1 x2 x3 x4];
th1=-7:0.1:0;
th2=0:0.1:7;
h1=zeros(size(th1));
h2=ones(size(th2));
h3=[h1 h2];
th=[th1 th2];
h4=exp(-th);
h=h3.*h4;
t=0;
plot(tx,x,-th+t,h,'-','linewidth',2)
ylim([-0.1 1.1])
legend('x(\tau)','h(t-\tau)')
grid

Best Answer

After the original code in your Question (not your subsequent Comment), add these lines:
hold on
Ltx = (tx >= -1) & (tx <= 0);
Ltht = (-th+t >= -1) & (-th+t <= 0);
xh = min([x(Ltx); h(Ltht)]);
patch([tx(Ltx) flip(tx(Ltx))], [zeros(size(xh)) xh], 'g')
hold off
to get this plot:
.