% Convolution between discrete signals (sequences) (emol)

clc % emol
clearvars % emol
close all % emol

x=[1 1 1 1 1 0 0 0 0];
h=[8 7 6 5 4 3 2 1 0 0 0];
nx=[0:length(x)-1];
nh=[0:length(h)-1];

y1=conv(h,x);
y2=conv(x,h);
ny=[0:length(y1)-1];

figure(1) % emol

subplot(2,2,1) % emol
stem(nx,x,'bo','filled') % emol
xlabel('\itn'); ylabel('\itx\rm(\itn\rm)')

subplot(2,2,2) % emol
stem(nh,h,'bd','filled') % emol
xlabel('\itn'); ylabel('\ith\rm(\itn\rm)')

subplot(2,2,3) % emol
stem(ny,y1,'bs','filled')
xlabel('\itn'); ylabel('\ity_1\rm(\itn\rm)')

subplot(2,2,4) % emol
stem(ny,y2,'rs','filled')
xlabel('\itn'); ylabel('\ity_2\rm(\itn\rm)')

% The lengths of y1 and y2 equal the 
% [(length of x) + (length of h) - 1]. 
% Why?