figure
xmax = 3000;
subplot(6,1,1)
L = 100;
f = ones(1,L);
plot(-100:200-1, [zeros(1,100) f zeros(1,100)],'k')
%title('h[n]')
ylim([0 2])
xlim([-100 xmax])
set(gca,'XTick',[]); set(gca,'YTick',[])
subplot(6,1,2)
a = [zeros(1,20) ones(1,L) zeros(1,300) 0.5*ones(1,100) zeros(1,1000-L-20-400)];
b = [zeros(1,1000-L-20) ones(1,L) zeros(1,20)];
a1 = [zeros(1,1000) a zeros(1,1000)];
b1 = [zeros(1,1000) b zeros(1,1000)];
plot(1:length(a1), a1, 'b', 1:length(a1), b1, 'r')
%title('x[n]')
ylim([0 2])
xlim([0 xmax])
set(gca,'XTick',[]); set(gca,'YTick',[])
subplot(6,1,3)
a1 = conv(a1,f);
b1 = conv(b1,f);
plot(1:length(a1), a1+b1, 'g')
%title('x[n] * h[n]')
ylim([0 2*max(a1)])
xlim([0 xmax])
set(gca,'XTick',[]); set(gca,'YTick',[])
subplot(6,1,4)
a = [a a a];
b = [b b b];
L = 1:length(a);
plot(L, a, 'b', L, b, 'r')
%title('x_N[n]')
ylim([0 2.5])
xlim([0 xmax])
set(gca,'XTick',[]); set(gca,'YTick',[])
subplot(6,1,5)
a1 = conv(a,f);
b1 = conv(b,f);
b1(1:90) = b1(3000+[1:90]);
L = 1:length(a1);
plot(L,a1,'b',L,b1,'r')
%title('components of x_N[n] * h[n]')
ylim([0 2*max(a1)])
xlim([0 xmax])
set(gca,'XTick',[]); set(gca,'YTick',[])
subplot(6,1,6)
c = a1+b1;
L = length(c);
k=1100;
plot(1:k, c(1:k), 'r', k+(1:900), c(k+(1:900)), 'g', (k+900+1):xmax, c((k+900+1):xmax), 'r')
%title('x_N[n] * h[n]')
ylim([0 2*max(a1+b1)])
xlim([0 xmax])
set(gca,'XTick',[]); set(gca,'YTick',[])