% Small program to check convolution
% Signal Processing class
% P. Gomez Gil, Sept 10, 2017

% Some examples to try
% x1 = [1 2 3];   %any signals
% x2 = [-2 1 -1 -1];

x1 = [1 1 1 ];      % first difference
% x1 = [1 1 1 1 1]; % running sum
x2 =  [1 4 7 2 3 ];
% x2o = x2;
% x1 = [1 1 1 1 1 1 1 0 0 0 0 0 0 0  ];  % 2 trains of pulses
% x2 = [1 1 1 1 1 1 1 0 0 0 0 0 0 0  ];

% x1 = [1 1 1 0 0 0];
% x2 = [1 1 1 0 0 0];

resultado = conv(x1,x2);

figure(1);
subplot(2,2,1);
stem(x1);
title('x1');
subplot(2,2,2);
stem(x2);
title('x2');
subplot(2,2,3);
stem(resultado);
title('x1*x2');
fprintf('the original signals are:');
x1
x2
resultado
fprintf('the size of signal x1 is %d\n',length(x1));
fprintf('the size of signal x2 is %d\n',length(x2));
fprintf('the size of resulting signal is %d\n',length(resultado));
