Está en la página 1de 50

UNIVERSIDAD NACIONAL DE SAN AGUSTN

FACULTAD DE PRODUCCIN Y SERVICIOS


ESCUELA PROFESIONAL DE INGENIERA EN
TELECOMUNICACIONES




SEMESTRE: IV
CURSO: PROCESAMIENTO DIGITAL DE SEALES
PROFESOR: ING. JUAN CARLOS CUADROS MACHUCA
TEMA: TERCER LABORATOTIO CONVOLUCIN
ESTUDIANTES: BANDA SAYCO, OSWALDO REN
HUANQUI SORIA, WILSON
FECHA: 13/12/2013


PRCTICA 3: CONVOLUCION

I. OBJETIVOS

Familiarizacin con la secuencia de pasos que permite calcular grficamente la
convolucin de dos seales discretas de duracin finita.

II. MATERIALES Y/O EQUIPOS A UTILIZAR

PC
MATLAB
Toolbox de DSP

III. DESARROLLO DE LA PRCTICA
CONVOLUCION:

1. Analice detenidamente el programa y explique cmo funciona y qu hace.
Por razones de simplicidad, se ha supuesto que las dos seales comienzan en cero y
que Lx y Lh son la duracin de x(n) y h(n) respectivamente. Por consiguiente, en el
programa se supone que x(n) se extiende entre 0 y Lx-1 y que h(n) se extiende entre
0 y Lh-1.

El programa calcula la convolucin entre dos seales de duracin finita, el proceso se
da paso a paso visualizando los resultados intermedios.
Primero se definen las dos seales a convolucionar y la longitud de las mismas. El paso
que sigue es dibujar ambas seales. Luego hay un bucle que realiza la convolucin paso
por paso mostrndonos figuras en el proceso. Al final obtenemos y(n) con su
respectiva grfica.

%Laboratorio de PDS-EPIT
%Prctica 3 ----> CONVOLUCIN
%Fecha: 13/12/2013
%Apellidos y nombres: Banda Sayco Oswaldo Ren
% Huanqui Soria Wilson
%-----------------------
%Solucin PROGRAMA DE CONVOLUCIN
clear all;
% Definicion de las seales a convolucionar
Lx=48; %Longitud de x(n)
equis=sin(pi*(0:Lx-1)/12 + pi/4); %x(n)
if size(equis) ~= Lx
error('Error: la senhal x(n) esta mal definida')
end;
Lh=15; %Longitud de h(n)
hache=(7/8).^(0:Lh-1); %h(n)
if size(hache) ~= Lh
error('Error: la senhal h(n) esta mal definida')
end;
% Dibujo de x(n) y h(n). Se aaden Lh ceros antes y despues
% para visualizar mejor las seales
ndib=-Lh:Lx+Lh;
subplot(211)
equisdib=[zeros(1,Lh) equis zeros(1,Lh+1)];
stem(ndib,equisdib);
title('x(n)');
subplot(212)
hachedib=[zeros(1,Lh) hache zeros(1,Lx+1)];
stem(ndib,hachedib);
title('h(n)');
pause;
% Bucle que realiza la convolucion
for n=0:Lx+Lh-1
% Construccion y dibujo de x(k)
xdek=[zeros(1,Lh) equis zeros(1,Lh+1)];
subplot(221)
stem(ndib,xdek);
title('x(k)')
xlabel('k')
grid;
% Construccion y dibujo de h(n-k)
hdenmenosk=[zeros(1,n+1) hache(Lh:-1:1) zeros(1,Lx+Lh-n)];
subplot(223)
stem(ndib,hdenmenosk);
title('h(n-k)')
xlabel('k')
grid;
% Dibujo de x(k)h(n-k)
subplot(222)
stem(ndib,xdek.*hdenmenosk);
title('x(k)h(n-k)')
xlabel('k')
grid;
% Obtencion y dibujo de y(n)
yden(n+1)=sum(xdek.*hdenmenosk);
subplot(224)
stem(-1:Lx+Lh,[0 yden zeros(1,Lx+Lh-n)]);
title('y(n)')
xlabel('n')
grid;
pause;
end;





2. Demuestre que con las suposiciones anteriores sobre las duraciones de x(n) y h(n)
la seal y(n)=x(n)*h(n) comienza en 0 y acaba en Lx+Lh-2 (su duracin, por tanto, es
Lx+Lh-1).

x(n) = [1 2 1 1] duracin de x(n) = 4
h(n) = [1 -1 1] duracin de h(n) = 3

h(n) = 1 -1 1
x(n) = 1 2 1 1
_____________________________________________
1 -1 1
2 -2 2
1 -1 1
1 -1 1
______________________________________________
y(n) = 1 1 0 2 0 1 duracin de y(n) = 6


3. Escriba en un fichero el programa convolucion.m que aparece al final del
enunciado. Utilice la instruccin help para consultar el funcionamiento y la sintaxis
de aquellas funciones de MATLAB que no conozca. Haga la convolucin entre las dos
siguientes seales:
x(n) = [1 2 1 1]
h(n) = [1 -1 1]

%Laboratorio de PDS-EPIT
%Prctica 3 ----> CONVOLUCIN
%Fecha: 13/12/2013
%Apellidos y nombres: Banda Sayco Oswaldo Ren
% Huanqui Soria Wilson
%-----------------------
%Solucin ejercicio_3

clear all;
% Definicion de las seales a convolucionar
Lx=4; %Longitud de x(n)
equis=[1 2 1 1]; %x(n)
if size(equis) ~= Lx
error('Error: la senhal x(n) esta mal definida')
end;
Lh=3; %Longitud de h(n)
hache=[1 -1 1]; %h(n)
if size(hache) ~= Lh
error('Error: la senhal h(n) esta mal definida')
end;

% Dibujo de x(n) y h(n). Se aaden Lh ceros antes y despues
% para visualizar mejor las seales
ndib=-Lh:Lx+Lh;
subplot(211)
equisdib=[zeros(1,Lh) equis zeros(1,Lh+1)];
stem(ndib,equisdib,'fill');
title('x(n)');
subplot(212)
hachedib=[zeros(1,Lh) hache zeros(1,Lx+1)];
stem(ndib,hachedib,'fill');
title('h(n)');
pause;

% Bucle que realiza la convolucion
for n=0:Lx+Lh-1
% Construccion y dibujo de x(k)
xdek=[zeros(1,Lh) equis zeros(1,Lh+1)];
subplot(221)
stem(ndib,xdek,'fill');
title('x(k)')
xlabel('k')
grid;
% Construccion y dibujo de h(n-k)
hdenmenosk=[zeros(1,n+1) hache(Lh:-1:1) zeros(1,Lx+Lh-n)];
subplot(223)
stem(ndib,hdenmenosk,'fill');
title('h(n-k)')
xlabel('k')
grid;
% Dibujo de x(k)h(n-k)
subplot(222)
stem(ndib,xdek.*hdenmenosk,'fill');
title('x(k)h(n-k)')
xlabel('k')
grid;
% Obtencion y dibujo de y(n)
yden(n+1)=sum(xdek.*hdenmenosk);
subplot(224)
stem(-1:Lx+Lh,[0 yden zeros(1,Lx+Lh-n)],'fill');
title('y(n)')
xlabel('n')
grid;
pause;
end;

Primero nos sale el dibujo de la seal x(n) junto con el dibujo de la seal h(n) que
introducimos.


Luego de eso nos salen cuatro dibujos en la misma Figure1. En la primera columna se
observa el dibujo de la seal x(k). Debajo de esta se observa el dibujo de la seal h(n-
k),
h(n-k) se obtiene reflejando h(k) sobre el eje k alrededor del punto k=0 para construir
h(-k) y despus desplazndola |n| muestras a la izquierda si n es negativo o n muestras
a la derecha si n es positivo.
En la segunda columna observamos primero el producto de x(k) y h(n - k), conforme se
va desplazando h(n-k). La figura de abajo a la derecha nos muestra la sumatoria de
convolucin.





4. Considere las siguientes seales:
x1(n) = [1 4 2 3 5 3 3 4 5 7 6 9]
x2(n) = [1 1]
x3(n) = [1 2 1]
x4(n) = [ ]
x5(n) = [ ]
x6(n) = [ - ]
x7(n) = [ -]
Modifique el programa del apartado anterior para efectuar las siguientes
convoluciones y observe los resultados obtenidos



a. x1(n) * x2(n)

%Solucin ejercicio_4_a

clear all;
% Definicion de las seales a convolucionar
Lx=12; %Longitud de x(n)
equis=[1 4 2 3 5 3 3 4 5 7 6 9]; %x(n)
if size(equis) ~= Lx
error('Error: la senhal x(n) esta mal definida')
end;
Lh=2; %Longitud de h(n)
hache=[1 1]; %h(n)
if size(hache) ~= Lh
error('Error: la senhal h(n) esta mal definida')
end;

% Dibujo de x(n) y h(n). Se aaden Lh ceros antes y despues
% para visualizar mejor las seales
ndib=-Lh:Lx+Lh;
subplot(211)
equisdib=[zeros(1,Lh) equis zeros(1,Lh+1)];
stem(ndib,equisdib,'fill');
title('x1(n)');
subplot(212)
hachedib=[zeros(1,Lh) hache zeros(1,Lx+1)];
stem(ndib,hachedib,'fill');
title('x2(n)');
pause;

% Bucle que realiza la convolucion
for n=0:Lx+Lh-1
% Construccion y dibujo de x(k)
xdek=[zeros(1,Lh) equis zeros(1,Lh+1)];
subplot(221)
stem(ndib,xdek,'fill');
title('x1(k)')
xlabel('k')
grid;
% Construccion y dibujo de h(n-k)
hdenmenosk=[zeros(1,n+1) hache(Lh:-1:1) zeros(1,Lx+Lh-n)];
subplot(223)
stem(ndib,hdenmenosk,'fill');
title('x2(n-k)')
xlabel('k')
grid;
% Dibujo de x(k)h(n-k)
subplot(222)
stem(ndib,xdek.*hdenmenosk,'fill');
title('x1(k)x2(n-k)')
xlabel('k')
grid;
% Obtencion y dibujo de y(n)
yden(n+1)=sum(xdek.*hdenmenosk);
subplot(224)
stem(-1:Lx+Lh,[0 yden zeros(1,Lx+Lh-n)],'fill');
title('y(n)')
xlabel('n')
grid;
pause;
end;




b. x1(n)*x4(n). Compare con el apartado anterior y vea que es lo mismo pero
multiplicado por .

Esta relacin se puede expresar as: x1(n)*x4(n) = (1/2)[x1(n)*x2(n)]

%Solucin ejercicio_4_b
clear all;
% Definicion de las seales a convolucionar
Lx=12; %Longitud de x(n)
equis=[1 4 2 3 5 3 3 4 5 7 6 9]; %x(n)
if size(equis) ~= Lx
error('Error: la senhal x(n) esta mal definida')
end;
Lh=2; %Longitud de h(n)
hache=[0.5 0.5]; %h(n)
if size(hache) ~= Lh
error('Error: la senhal h(n) esta mal definida')
end;
% Dibujo de x(n) y h(n). Se aaden Lh ceros antes y despues
% para visualizar mejor las seales
ndib=-Lh:Lx+Lh;
subplot(211)
equisdib=[zeros(1,Lh) equis zeros(1,Lh+1)];
stem(ndib,equisdib,'fill');
title('x1(n)');
subplot(212)
hachedib=[zeros(1,Lh) hache zeros(1,Lx+1)];
stem(ndib,hachedib,'fill');
title('x4(n)');
pause;
% Bucle que realiza la convolucion
for n=0:Lx+Lh-1
% Construccion y dibujo de x(k)
xdek=[zeros(1,Lh) equis zeros(1,Lh+1)];
subplot(221)
stem(ndib,xdek,'fill');
title('x1(k)')
xlabel('k')
grid;
% Construccion y dibujo de h(n-k)
hdenmenosk=[zeros(1,n+1) hache(Lh:-1:1) zeros(1,Lx+Lh-n)];
subplot(223)
stem(ndib,hdenmenosk,'fill');
title('x4(n-k)')
xlabel('k')
grid;
% Dibujo de x(k)h(n-k)
subplot(222)
stem(ndib,xdek.*hdenmenosk,'fill');
title('x1(k)x4(n-k)')
xlabel('k')
grid;
% Obtencion y dibujo de y(n)
yden(n+1)=sum(xdek.*hdenmenosk);
subplot(224)
stem(-1:Lx+Lh,[0 yden zeros(1,Lx+Lh-n)],'fill');
title('y(n)')
xlabel('n')
grid;
pause;
end;




c. x1(n) * x7(n). Compare con el apartado anterior.

La convolucin 4_c se relaciona con la convolucin 4_b de la siguiente manera:

x1(n)*x7(n) = x1(n)*x4(n) x1(n-1)

%Solucin ejercicio_4_c
clear all;
% Definicion de las seales a convolucionar
Lx=12; %Longitud de x(n)
equis=[1 4 2 3 5 3 3 4 5 7 6 9]; %x(n)
if size(equis) ~= Lx
error('Error: la senhal x(n) esta mal definida')
end;
Lh=2; %Longitud de h(n)
hache=[0.5 -0.5]; %h(n)
if size(hache) ~= Lh
error('Error: la senhal h(n) esta mal definida')
end;
% Dibujo de x(n) y h(n). Se aaden Lh ceros antes y despues
% para visualizar mejor las seales
ndib=-Lh:Lx+Lh;
subplot(211)
equisdib=[zeros(1,Lh) equis zeros(1,Lh+1)];
stem(ndib,equisdib,'fill');
title('x1(n)');
subplot(212)
hachedib=[zeros(1,Lh) hache zeros(1,Lx+1)];
stem(ndib,hachedib,'fill');
title('x7(n)');
pause;
% Bucle que realiza la convolucion
for n=0:Lx+Lh-1
% Construccion y dibujo de x(k)
xdek=[zeros(1,Lh) equis zeros(1,Lh+1)];
subplot(221)
stem(ndib,xdek,'fill');
title('x1(k)')
xlabel('k')
grid;
% Construccion y dibujo de h(n-k)
hdenmenosk=[zeros(1,n+1) hache(Lh:-1:1) zeros(1,Lx+Lh-n)];
subplot(223)
stem(ndib,hdenmenosk,'fill');
title('x7(n-k)')
xlabel('k')
grid;
% Dibujo de x(k)h(n-k)
subplot(222)
stem(ndib,xdek.*hdenmenosk,'fill');
title('x1(k)x7(n-k)')
xlabel('k')
grid;
% Obtencion y dibujo de y(n)
yden(n+1)=sum(xdek.*hdenmenosk);
subplot(224)
stem(-1:Lx+Lh,[0 yden zeros(1,Lx+Lh-n)],'fill');
title('y(n)')
xlabel('n')
grid;
pause;
end;




d. x1(n) * x3(n)

%Solucin ejercicio_4_d
clear all;
% Definicion de las seales a convolucionar
Lx=12; %Longitud de x(n)
equis=[1 4 2 3 5 3 3 4 5 7 6 9]; %x(n)
if size(equis) ~= Lx
error('Error: la senhal x(n) esta mal definida')
end;
Lh=3; %Longitud de h(n)
hache=[1 2 1]; %h(n)
if size(hache) ~= Lh
error('Error: la senhal h(n) esta mal definida')
end;
% Dibujo de x(n) y h(n). Se aaden Lh ceros antes y despues
% para visualizar mejor las seales
ndib=-Lh:Lx+Lh;
subplot(211)
equisdib=[zeros(1,Lh) equis zeros(1,Lh+1)];
stem(ndib,equisdib,'fill');
title('x1(n)');
subplot(212)
hachedib=[zeros(1,Lh) hache zeros(1,Lx+1)];
stem(ndib,hachedib,'fill');
title('x3(n)');
pause;
% Bucle que realiza la convolucion
for n=0:Lx+Lh-1
% Construccion y dibujo de x(k)
xdek=[zeros(1,Lh) equis zeros(1,Lh+1)];
subplot(221)
stem(ndib,xdek,'fill');
title('x1(k)')
xlabel('k')
grid;
% Construccion y dibujo de h(n-k)
hdenmenosk=[zeros(1,n+1) hache(Lh:-1:1) zeros(1,Lx+Lh-n)];
subplot(223)
stem(ndib,hdenmenosk,'fill');
title('x3(n-k)')
xlabel('k')
grid;
% Dibujo de x(k)h(n-k)
subplot(222)
stem(ndib,xdek.*hdenmenosk,'fill');
title('x1(k)x3(n-k)')
xlabel('k')
grid;
% Obtencion y dibujo de y(n)
yden(n+1)=sum(xdek.*hdenmenosk);
subplot(224)
stem(-1:Lx+Lh,[0 yden zeros(1,Lx+Lh-n)],'fill');
title('y(n)')
xlabel('n')
grid;
pause;
end;





e. x1(n) * x5(n). Compare con el apartado anterior y vea que es lo mismo pero
multiplicado por .

En realidad no es lo mismo multiplicado las convoluciones varan porque las seales
x3(n) y x5(n) no son proporcionales. Esto se puede observar en los grficos.

La relacin sera la siguiente: x1(n)*x5(n) = (1/2)[x1(n)*x3(n)] (3/4)x1(n-1)

%Solucin ejercicio_4_e

clear all;
% Definicion de las seales a convolucionar
Lx=12; %Longitud de x(n)
equis=[1 4 2 3 5 3 3 4 5 7 6 9]; %x(n)
if size(equis) ~= Lx
error('Error: la senhal x(n) esta mal definida')
end;
Lh=3; %Longitud de h(n)
hache=[0.5 0.25 0.5]; %h(n)
if size(hache) ~= Lh
error('Error: la senhal h(n) esta mal definida')
end;

% Dibujo de x(n) y h(n). Se aaden Lh ceros antes y despues
% para visualizar mejor las seales
ndib=-Lh:Lx+Lh;
subplot(211)
equisdib=[zeros(1,Lh) equis zeros(1,Lh+1)];
stem(ndib,equisdib,'fill');
title('x1(n)');
subplot(212)
hachedib=[zeros(1,Lh) hache zeros(1,Lx+1)];
stem(ndib,hachedib,'fill');
title('x5(n)');
pause;

% Bucle que realiza la convolucion
for n=0:Lx+Lh-1
% Construccion y dibujo de x(k)
xdek=[zeros(1,Lh) equis zeros(1,Lh+1)];
subplot(221)
stem(ndib,xdek,'fill');
title('x1(k)')
xlabel('k')
grid;
% Construccion y dibujo de h(n-k)
hdenmenosk=[zeros(1,n+1) hache(Lh:-1:1) zeros(1,Lx+Lh-n)];
subplot(223)
stem(ndib,hdenmenosk,'fill');
title('x5(n-k)')
xlabel('k')
grid;
% Dibujo de x(k)h(n-k)
subplot(222)
stem(ndib,xdek.*hdenmenosk,'fill');
title('x1(k)x5(n-k)')
xlabel('k')
grid;
% Obtencion y dibujo de y(n)
yden(n+1)=sum(xdek.*hdenmenosk);
subplot(224)
stem(-1:Lx+Lh,[0 yden zeros(1,Lx+Lh-n)],'fill');
title('y(n)')
xlabel('n')
grid;
pause;
end;





f. x1(n) * x6(n). Compare con el apartado anterior.

Podemos comparar ambas seales de la siguiente manera:

x1(n)*x6(n) = (1/2)[x1(n)*x5(n)] (5/8)x1(n-1)

%Solucin ejercicio_4_f
clear all;
% Definicion de las seales a convolucionar
Lx=12; %Longitud de x(n)
equis=[1 4 2 3 5 3 3 4 5 7 6 9]; %x(n)
if size(equis) ~= Lx
error('Error: la senhal x(n) esta mal definida')
end;
Lh=3; %Longitud de h(n)
hache=[0.25 -0.5 0.25]; %h(n)
if size(hache) ~= Lh
error('Error: la senhal h(n) esta mal definida')
end;
% Dibujo de x(n) y h(n). Se aaden Lh ceros antes y despues
% para visualizar mejor las seales
ndib=-Lh:Lx+Lh;
subplot(211)
equisdib=[zeros(1,Lh) equis zeros(1,Lh+1)];
stem(ndib,equisdib,'fill');
title('x1(n)');
subplot(212)
hachedib=[zeros(1,Lh) hache zeros(1,Lx+1)];
stem(ndib,hachedib,'fill');
title('x6(n)');
pause;
% Bucle que realiza la convolucion
for n=0:Lx+Lh-1
% Construccion y dibujo de x(k)
xdek=[zeros(1,Lh) equis zeros(1,Lh+1)];
subplot(221)
stem(ndib,xdek,'fill');
title('x1(k)')
xlabel('k')
grid;
% Construccion y dibujo de h(n-k)
hdenmenosk=[zeros(1,n+1) hache(Lh:-1:1) zeros(1,Lx+Lh-n)];
subplot(223)
stem(ndib,hdenmenosk,'fill');
title('x6(n-k)')
xlabel('k')
grid;
% Dibujo de x(k)h(n-k)
subplot(222)
stem(ndib,xdek.*hdenmenosk,'fill');
title('x1(k)x6(n-k)')
xlabel('k')
grid;
% Obtencion y dibujo de y(n)
yden(n+1)=sum(xdek.*hdenmenosk);
subplot(224)
stem(-1:Lx+Lh,[0 yden zeros(1,Lx+Lh-n)],'fill');
title('y(n)')
xlabel('n')
grid;
pause;
end;




5. Ahora considere estas seales:

x8(n) = u(n) - u(n - 5)
x9(n) = u(n) - u(n - 10)




Vuelva a modificar el programa anterior para efectuar las siguientes convoluciones y
observe los resultados obtenidos.
a. x8(n) * x8(n)
Se observa la convolucin de una seal finita entre s misma. La sumatoria de
convolucin tiene una forma triangular. La duracin de la seal de convolucin es igual
al doble de la duracin de x8(n), menos uno.
%Solucin ejercicio_5_a

clear all;
% Definicion de las seales a convolucionar
Lx=5; %Longitud de x(n)
equis=[ones(1,5)]; %x(n)
if size(equis) ~= Lx
error('Error: la senhal x(n) esta mal definida')
end;
Lh=5; %Longitud de h(n)
hache=[ones(1,5)]; %h(n)
if size(hache) ~= Lh
error('Error: la senhal h(n) esta mal definida')
end;

% Dibujo de x(n) y h(n). Se aaden Lh ceros antes y despues
% para visualizar mejor las seales
ndib=-Lh:Lx+Lh;
subplot(211)
equisdib=[zeros(1,Lh) equis zeros(1,Lh+1)];
stem(ndib,equisdib,'fill');
title('x8(n)');
subplot(212)
hachedib=[zeros(1,Lh) hache zeros(1,Lx+1)];
stem(ndib,hachedib,'fill');
title('x8(n)');
pause;

% Bucle que realiza la convolucion
for n=0:Lx+Lh-1
% Construccion y dibujo de x(k)
xdek=[zeros(1,Lh) equis zeros(1,Lh+1)];
subplot(221)
stem(ndib,xdek,'fill');
title('x8(k)')
xlabel('k')
grid;
% Construccion y dibujo de h(n-k)
hdenmenosk=[zeros(1,n+1) hache(Lh:-1:1) zeros(1,Lx+Lh-n)];
subplot(223)
stem(ndib,hdenmenosk,'fill');
title('x8(n-k)')
xlabel('k')
grid;
% Dibujo de x(k)h(n-k)
subplot(222)
stem(ndib,xdek.*hdenmenosk,'fill');
title('x8(k)x8(n-k)')
xlabel('k')
grid;
% Obtencion y dibujo de y(n)
yden(n+1)=sum(xdek.*hdenmenosk);
subplot(224)
stem(-1:Lx+Lh,[0 yden zeros(1,Lx+Lh-n)],'fill');
title('y(n)')
xlabel('n')
grid;
pause;
end;



b. x9(n) * x9(n)
Convolucin de dos seales idnticas finitas. La respuesta tiene forma triangular como
en el caso anterior. La duracin de la seal de convolucin es igual al doble de la
duracin de x9(n), menos uno.
%Solucin ejercicio_5_b
clear all;
% Definicion de las seales a convolucionar
Lx=10; %Longitud de x(n)
equis=[ones(1,10)]; %x(n)
if size(equis) ~= Lx
error('Error: la senhal x(n) esta mal definida')
end;
Lh=10; %Longitud de h(n)
hache=[ones(1,10)]; %h(n)
if size(hache) ~= Lh
error('Error: la senhal h(n) esta mal definida')
end;
% Dibujo de x(n) y h(n). Se aaden Lh ceros antes y despues
% para visualizar mejor las seales
ndib=-Lh:Lx+Lh;
subplot(211)
equisdib=[zeros(1,Lh) equis zeros(1,Lh+1)];
stem(ndib,equisdib,'fill');
title('x9(n)');
subplot(212)
hachedib=[zeros(1,Lh) hache zeros(1,Lx+1)];
stem(ndib,hachedib,'fill');
title('x9(n)');
pause;

% Bucle que realiza la convolucion
for n=0:Lx+Lh-1
% Construccion y dibujo de x(k)
xdek=[zeros(1,Lh) equis zeros(1,Lh+1)];
subplot(221)
stem(ndib,xdek,'fill');
title('x9(k)')
xlabel('k')
grid;
% Construccion y dibujo de h(n-k)
hdenmenosk=[zeros(1,n+1) hache(Lh:-1:1) zeros(1,Lx+Lh-n)];
subplot(223)
stem(ndib,hdenmenosk,'fill');
title('x9(n-k)')
xlabel('k')
grid;
% Dibujo de x(k)h(n-k)
subplot(222)
stem(ndib,xdek.*hdenmenosk,'fill');
title('x9(k)x9(n-k)')
xlabel('k')
grid;
% Obtencion y dibujo de y(n)
yden(n+1)=sum(xdek.*hdenmenosk);
subplot(224)
stem(-1:Lx+Lh,[0 yden zeros(1,Lx+Lh-n)],'fill');
title('y(n)')
xlabel('n')
grid;
pause;
end;



c. x8(n) * x9(n)
Convolucin de dos seales finitas. La respuesta tiene forma geomtrica como en los
casos anteriores. La duracin de la seal de convolucin es igual a:
Duracin de y(n) = Duracin de x8(n) + Duracin de x9(n) - 1
%Solucin ejercicio_5_c
clear all;
% Definicion de las seales a convolucionar
Lx=5; %Longitud de x(n)
equis=[ones(1,5)]; %x(n)
if size(equis) ~= Lx
error('Error: la senhal x(n) esta mal definida')
end;
Lh=10; %Longitud de h(n)
hache=[ones(1,10)]; %h(n)
if size(hache) ~= Lh
error('Error: la senhal h(n) esta mal definida')
end;
% Dibujo de x(n) y h(n). Se aaden Lh ceros antes y despues
% para visualizar mejor las seales
ndib=-Lh:Lx+Lh;
subplot(211)
equisdib=[zeros(1,Lh) equis zeros(1,Lh+1)];
stem(ndib,equisdib,'fill');
title('x8(n)');
subplot(212)
hachedib=[zeros(1,Lh) hache zeros(1,Lx+1)];
stem(ndib,hachedib,'fill');
title('x9(n)');
pause;
% Bucle que realiza la convolucion
for n=0:Lx+Lh-1
% Construccion y dibujo de x(k)
xdek=[zeros(1,Lh) equis zeros(1,Lh+1)];
subplot(221)
stem(ndib,xdek,'fill');
title('x8(k)')
xlabel('k')
grid;
% Construccion y dibujo de h(n-k)
hdenmenosk=[zeros(1,n+1) hache(Lh:-1:1) zeros(1,Lx+Lh-n)];
subplot(223)
stem(ndib,hdenmenosk,'fill');
title('x9(n-k)')
xlabel('k')
grid;
% Dibujo de x(k)h(n-k)
subplot(222)
stem(ndib,xdek.*hdenmenosk,'fill');
title('x8(k)x9(n-k)')
xlabel('k')
grid;
% Obtencion y dibujo de y(n)
yden(n+1)=sum(xdek.*hdenmenosk);
subplot(224)
stem(-1:Lx+Lh,[0 yden zeros(1,Lx+Lh-n)],'fill');
title('y(n)')
xlabel('n')
grid;
pause;
end;



d. x8(n) * x9(n - 3). Compare con el apartado anterior y vea que es lo mismo pero
desplazado 3 unidades.

La seal x8(n)*x9(n - 3) es igual a x8(n)*x9(n) retrasada 3 unidades.

Esta convolucin mantiene la duracin hallada en el apartado anterior.

%Solucin ejercicio_5_d
clear all;
% Definicion de las seales a convolucionar
Lx=5; %Longitud de x(n)
equis=[ones(1,5)]; %x(n)
if size(equis) ~= Lx
error('Error: la senhal x(n) esta mal definida')
end;
Lh=13; %Longitud de h(n)
hache=[zeros(1,3) ones(1,10)]; %h(n)
if size(hache) ~= Lh
error('Error: la senhal h(n) esta mal definida')
end;
% Dibujo de x(n) y h(n). Se aaden Lh ceros antes y despues
% para visualizar mejor las seales
ndib=-Lh:Lx+Lh;
subplot(211)
equisdib=[zeros(1,Lh) equis zeros(1,Lh+1)];
stem(ndib,equisdib,'fill');
title('x8(n)');
subplot(212)
hachedib=[zeros(1,Lh) hache zeros(1,Lx+1)];
stem(ndib,hachedib,'fill');
title('x9(n-3)');
pause;
% Bucle que realiza la convolucion
for n=0:Lx+Lh-1
% Construccion y dibujo de x(k)
xdek=[zeros(1,Lh) equis zeros(1,Lh+1)];
subplot(221)
stem(ndib,xdek,'fill');
title('x8(k)')
xlabel('k')
grid;
% Construccion y dibujo de h(n-k)
hdenmenosk=[zeros(1,n+1) hache(Lh:-1:1) zeros(1,Lx+Lh-n)];
subplot(223)
stem(ndib,hdenmenosk,'fill');
title('x9(n-3-k)')
xlabel('k')
grid;
% Dibujo de x(k)h(n-k)
subplot(222)
stem(ndib,xdek.*hdenmenosk,'fill');
title('x8(k)x9(n-3-k)')
xlabel('k')
grid;
% Obtencion y dibujo de y(n)
yden(n+1)=sum(xdek.*hdenmenosk);
subplot(224)
stem(-1:Lx+Lh,[0 yden zeros(1,Lx+Lh-n)],'fill');
title('y(n)')
xlabel('n')
grid;
pause;
end;


e. x8(n - 2) * x9(n - 4). Compare con los dos apartados anteriores y vea que es lo
mismo pero el resultado esta desplazado.
La seal x8(n - 2) * x9(n - 4) es igual a x8(n)*x9(n) con un retraso de 6 unidades. La
duracin de la convolucin se mantiene igual que en los apartados anteriores.
%Solucin ejercicio_5_e
clear all;
% Definicion de las seales a convolucionar
Lx=7; %Longitud de x(n)
equis=[zeros(1,2) ones(1,5)]; %x(n)
if size(equis) ~= Lx
error('Error: la senhal x(n) esta mal definida')
end;
Lh=14; %Longitud de h(n)
hache=[zeros(1,4) ones(1,10)]; %h(n)
if size(hache) ~= Lh
error('Error: la senhal h(n) esta mal definida')
end;
% Dibujo de x(n) y h(n). Se aaden Lh ceros antes y despues
% para visualizar mejor las seales
ndib=-Lh:Lx+Lh;
subplot(211)
equisdib=[zeros(1,Lh) equis zeros(1,Lh+1)];
stem(ndib,equisdib,'fill');
title('x8(n-2)');
subplot(212)
hachedib=[zeros(1,Lh) hache zeros(1,Lx+1)];
stem(ndib,hachedib,'fill');
title('x9(n-4)');
pause;
% Bucle que realiza la convolucion
for n=0:Lx+Lh-1
% Construccion y dibujo de x(k)
xdek=[zeros(1,Lh) equis zeros(1,Lh+1)];
subplot(221)
stem(ndib,xdek,'fill');
title('x8(k)')
xlabel('k')
grid;
% Construccion y dibujo de h(n-k)
hdenmenosk=[zeros(1,n+1) hache(Lh:-1:1) zeros(1,Lx+Lh-n)];
subplot(223)
stem(ndib,hdenmenosk,'fill');
title('x9(n-4-k)')
xlabel('k')
grid;
% Dibujo de x(k)h(n-k)
subplot(222)
stem(ndib,xdek.*hdenmenosk,'fill');
title('x8(k)x9(n-4-k)')
xlabel('k')
grid;
% Obtencion y dibujo de y(n)
yden(n+1)=sum(xdek.*hdenmenosk);
subplot(224)
stem(-1:Lx+Lh,[0 yden zeros(1,Lx+Lh-n)],'fill');
title('y(n)')
xlabel('n')
grid;
pause;
end;


f. x11(n) * x8(n)
%Solucin ejercicio_5_f

clear all;
% Definicion de las seales a convolucionar
Lx=36; %Longitud de x(n)
equis=sin(pi*(0:Lx-1)/12 + pi/4); %x(n)
if size(equis) ~= Lx
error('Error: la senhal x(n) esta mal definida')
end;
Lh=5; %Longitud de h(n)
hache=[ones(1,5)]; %h(n)
if size(hache) ~= Lh
error('Error: la senhal h(n) esta mal definida')
end;
% Dibujo de x(n) y h(n). Se aaden Lh ceros antes y despues
% para visualizar mejor las seales
ndib=-Lh:Lx+Lh;
subplot(211)
equisdib=[zeros(1,Lh) equis zeros(1,Lh+1)];
stem(ndib,equisdib,'fill');
title('x11(n)');
subplot(212)
hachedib=[zeros(1,Lh) hache zeros(1,Lx+1)];
stem(ndib,hachedib,'fill');
title('x8(n)');
pause;
% Bucle que realiza la convolucion
for n=0:Lx+Lh-1
% Construccion y dibujo de x(k)
xdek=[zeros(1,Lh) equis zeros(1,Lh+1)];
subplot(221)
stem(ndib,xdek,'fill');
title('x11(k)')
xlabel('k')
grid;
% Construccion y dibujo de h(n-k)
hdenmenosk=[zeros(1,n+1) hache(Lh:-1:1) zeros(1,Lx+Lh-n)];
subplot(223)
stem(ndib,hdenmenosk,'fill');
title('x8(n-k)')
xlabel('k')
grid;
% Dibujo de x(k)h(n-k)
subplot(222)
stem(ndib,xdek.*hdenmenosk,'fill');
title('x11(k)x8(n-k)')
xlabel('k')
grid;
% Obtencion y dibujo de y(n)
yden(n+1)=sum(xdek.*hdenmenosk);
subplot(224)
stem(-1:Lx+Lh,[0 yden zeros(1,Lx+Lh-n)],'fill');
title('y(n)')
xlabel('n')
grid;
pause;
end;





g. x11(n) * x9(n). Compare con el apartado anterior y vea que es lo mismo pero el
resultado esta desplazado.
En realidad la seal de convolucin no se ha desplazado, ms bien se observa que la
amplitud de la seal sinusoidal ha aumentado al igual que su periodo. Sin embargo
tambin se observa que la duracin de la seal de convolucin ha cambiado y en este
caso es mayor que en el apartado anterior.
%Solucin ejercicio_5_g

clear all;
% Definicion de las seales a convolucionar
Lx=36; %Longitud de x(n)
equis=sin(pi*(0:Lx-1)/12 + pi/4); %x(n)
if size(equis) ~= Lx
error('Error: la senhal x(n) esta mal definida')
end;
Lh=10; %Longitud de h(n)
hache=[ones(1,10)]; %h(n)
if size(hache) ~= Lh
error('Error: la senhal h(n) esta mal definida')
end;

% Dibujo de x(n) y h(n). Se aaden Lh ceros antes y despues
% para visualizar mejor las seales
ndib=-Lh:Lx+Lh;
subplot(211)
equisdib=[zeros(1,Lh) equis zeros(1,Lh+1)];
stem(ndib,equisdib,'fill');
title('x11(n)');
subplot(212)
hachedib=[zeros(1,Lh) hache zeros(1,Lx+1)];
stem(ndib,hachedib,'fill');
title('x9(n)');
pause;

% Bucle que realiza la convolucion
for n=0:Lx+Lh-1
% Construccion y dibujo de x(k)
xdek=[zeros(1,Lh) equis zeros(1,Lh+1)];
subplot(221)
stem(ndib,xdek,'fill');
title('x11(k)')
xlabel('k')
grid;
% Construccion y dibujo de h(n-k)
hdenmenosk=[zeros(1,n+1) hache(Lh:-1:1) zeros(1,Lx+Lh-n)];
subplot(223)
stem(ndib,hdenmenosk,'fill');
title('x9(n-k)')
xlabel('k')
grid;
% Dibujo de x(k)h(n-k)
subplot(222)
stem(ndib,xdek.*hdenmenosk,'fill');
title('x11(k)x9(n-k)')
xlabel('k')
grid;
% Obtencion y dibujo de y(n)
yden(n+1)=sum(xdek.*hdenmenosk);
subplot(224)
stem(-1:Lx+Lh,[0 yden zeros(1,Lx+Lh-n)],'fill');
title('y(n)')
xlabel('n')
grid;
pause;
end;



h. x11(n) * x10(n). Compare con los dos apartados anteriores.
Observamos que la convolucin produce una seal que aparentemente es sinusoidal,
pero en los ltimos pulsos pierde esa forma debido a la sumatoria de x11(k)x10(n-k).
La duracin de esta convolucin es mayor que en los apartados anteriores.
%Solucin ejercicio_5_h
clear all;
% Definicion de las seales a convolucionar
Lx=36; %Longitud de x(n)
equis=sin(pi*(0:Lx-1)/12 + pi/4); %x(n)
if size(equis) ~= Lx
error('Error: la senhal x(n) esta mal definida')
end;
Lh=15; %Longitud de h(n)
hache=(7/8).^(0:Lh-1); %h(n)
if size(hache) ~= Lh
error('Error: la senhal h(n) esta mal definida')
end;
% Dibujo de x(n) y h(n). Se aaden Lh ceros antes y despues
% para visualizar mejor las seales
ndib=-Lh:Lx+Lh;
subplot(211)
equisdib=[zeros(1,Lh) equis zeros(1,Lh+1)];
stem(ndib,equisdib,'fill');
title('x11(n)');
subplot(212)
hachedib=[zeros(1,Lh) hache zeros(1,Lx+1)];
stem(ndib,hachedib,'fill');
title('x10(n)');
pause;
% Bucle que realiza la convolucion
for n=0:Lx+Lh-1
% Construccion y dibujo de x(k)
xdek=[zeros(1,Lh) equis zeros(1,Lh+1)];
subplot(221)
stem(ndib,xdek,'fill');
title('x11(k)')
xlabel('k')
grid;
% Construccion y dibujo de h(n-k)
hdenmenosk=[zeros(1,n+1) hache(Lh:-1:1) zeros(1,Lx+Lh-n)];
subplot(223)
stem(ndib,hdenmenosk,'fill');
title('x10(n-k)')
xlabel('k')
grid;
% Dibujo de x(k)h(n-k)
subplot(222)
stem(ndib,xdek.*hdenmenosk,'fill');
title('x11(k)x10(n-k)')
xlabel('k')
grid;
% Obtencion y dibujo de y(n)
yden(n+1)=sum(xdek.*hdenmenosk);
subplot(224)
stem(-1:Lx+Lh,[0 yden zeros(1,Lx+Lh-n)],'fill');
title('y(n)')
xlabel('n')
grid;
pause;
end;



i. x10(n) * x9(n)
Se puede decir que:
Duracin de x10(n) + Duracin de x9(n) 1 = Duracin de y(n)
15 + 10 1 = 24 Duracin de y(n) =
24

Nuestra seal de convolucin y(n) se extiende desde n=0 hasta n=23
%Solucin ejercicio_5_i

clear all;
% Definicion de las seales a convolucionar
Lx=15; %Longitud de x(n)
equis=(7/8).^(0:Lx-1); %x(n)
if size(equis) ~= Lx
error('Error: la senhal x(n) esta mal definida')
end;
Lh=10; %Longitud de h(n)
hache=[ones(1,10)]; %h(n)
if size(hache) ~= Lh
error('Error: la senhal h(n) esta mal definida')
end;

% Dibujo de x(n) y h(n). Se aaden Lh ceros antes y despues
% para visualizar mejor las seales
ndib=-Lh:Lx+Lh;
subplot(211)
equisdib=[zeros(1,Lh) equis zeros(1,Lh+1)];
stem(ndib,equisdib,'fill');
title('x10(n)');
subplot(212)
hachedib=[zeros(1,Lh) hache zeros(1,Lx+1)];
stem(ndib,hachedib,'fill');
title('x9(n)');
pause;
% Bucle que realiza la convolucion
for n=0:Lx+Lh-1
% Construccion y dibujo de x(k)
xdek=[zeros(1,Lh) equis zeros(1,Lh+1)];
subplot(221)
stem(ndib,xdek,'fill');
title('x10(k)')
xlabel('k')
grid;
% Construccion y dibujo de h(n-k)
hdenmenosk=[zeros(1,n+1) hache(Lh:-1:1) zeros(1,Lx+Lh-n)];
subplot(223)
stem(ndib,hdenmenosk,'fill');
title('x9(n-k)')
xlabel('k')
grid;
% Dibujo de x(k)h(n-k)
subplot(222)
stem(ndib,xdek.*hdenmenosk,'fill');
title('x10(k)x9(n-k)')
xlabel('k')
grid;
% Obtencion y dibujo de y(n)
yden(n+1)=sum(xdek.*hdenmenosk);
subplot(224)
stem(-1:Lx+Lh,[0 yden zeros(1,Lx+Lh-n)],'fill');
title('y(n)')
xlabel('n')
grid;
pause;
end;



j. x10(n) * x10(n)

Se observa la convolucin de dos seales idnticas. La convolucin que obtenemos en
este caso no tiene una forma simtrica. La seal de convolucin se extiende desde n=0
hasta n=28

%Solucin ejercicio_5_j
clear all;
% Definicion de las seales a convolucionar
Lx=15; %Longitud de x(n)
equis=(7/8).^(0:Lx-1); %x(n)
if size(equis) ~= Lx
error('Error: la senhal x(n) esta mal definida')
end;
Lh=15; %Longitud de h(n)
hache=(7/8).^(0:Lh-1); %h(n)
if size(hache) ~= Lh
error('Error: la senhal h(n) esta mal definida')
end;
% Dibujo de x(n) y h(n). Se aaden Lh ceros antes y despues
% para visualizar mejor las seales
ndib=-Lh:Lx+Lh;
subplot(211)
equisdib=[zeros(1,Lh) equis zeros(1,Lh+1)];
stem(ndib,equisdib,'fill');
title('x10(n)');
subplot(212)
hachedib=[zeros(1,Lh) hache zeros(1,Lx+1)];
stem(ndib,hachedib,'fill');
title('x10(n)');
pause;
% Bucle que realiza la convolucion
for n=0:Lx+Lh-1
% Construccion y dibujo de x(k)
xdek=[zeros(1,Lh) equis zeros(1,Lh+1)];
subplot(221)
stem(ndib,xdek,'fill');
title('x10(k)')
xlabel('k')
grid;
% Construccion y dibujo de h(n-k)
hdenmenosk=[zeros(1,n+1) hache(Lh:-1:1) zeros(1,Lx+Lh-n)];
subplot(223)
stem(ndib,hdenmenosk,'fill');
title('x10(n-k)')
xlabel('k')
grid;
% Dibujo de x(k)h(n-k)
subplot(222)
stem(ndib,xdek.*hdenmenosk,'fill');
title('x10(k)x10(n-k)')
xlabel('k')
grid;
% Obtencion y dibujo de y(n)
yden(n+1)=sum(xdek.*hdenmenosk);
subplot(224)
stem(-1:Lx+Lh,[0 yden zeros(1,Lx+Lh-n)],'fill');
title('y(n)')
xlabel('n')
grid;
pause;
end;











6. La convolucin tiene las siguientes propiedades:

Conmutativa: x(n) * h(n) = h(n) * x(n)
Distributiva: x(n) * [h1(n) + h2(n)] = x(n) * h1(n) + x(n) * h2(n)
Asociativa: [x(n) * h1(n)] * h2(n) = x(n) * [h1(n) * h2(n)]

Verifique que estas propiedades se cumplen efectuando las convoluciones de los dos
lados de las siguientes igualdades:
a. x1(n) * x2(n) = x2(n) * x1(n)

%Solucin ejercicio_6_a

clear all;
% Definicion de las seales a convolucionar
Lx=12; %Longitud de x(n)
equis=[1 4 2 3 5 3 3 4 5 7 6 9]; %x(n)
if size(equis) ~= Lx
error('Error: la senhal x(n) esta mal definida')
end;
Lh=2; %Longitud de h(n)
hache=[1 1]; %h(n)
if size(hache) ~= Lh
error('Error: la senhal h(n) esta mal definida')
end;
figure(1);

% Dibujo de x(n) y h(n). Se aaden Lh ceros antes y despues
% para visualizar mejor las seales
ndib=-Lh:Lx+Lh;
subplot(211)
equisdib=[zeros(1,Lh) equis zeros(1,Lh+1)];
stem(ndib,equisdib,'fill');
title('x1(n)');
subplot(212)
hachedib=[zeros(1,Lh) hache zeros(1,Lx+1)];
stem(ndib,hachedib,'fill');
title('x2(n)');
pause;

% Bucle que realiza la convolucion
for n=0:Lx+Lh-1
% Construccion y dibujo de x(k)
xdek=[zeros(1,Lh) equis zeros(1,Lh+1)];
subplot(221)
stem(ndib,xdek,'fill');
title('x1(k)')
xlabel('k')
grid;
% Construccion y dibujo de h(n-k)
hdenmenosk=[zeros(1,n+1) hache(Lh:-1:1) zeros(1,Lx+Lh-n)];
subplot(223)
stem(ndib,hdenmenosk,'fill');
title('x2(n-k)')
xlabel('k')
grid;
% Dibujo de x(k)h(n-k)
subplot(222)
stem(ndib,xdek.*hdenmenosk,'fill');
title('x1(k)x2(n-k)')
xlabel('k')
grid;
% Obtencion y dibujo de y(n)
yden(n+1)=sum(xdek.*hdenmenosk);
subplot(224)
stem(-1:Lx+Lh,[0 yden zeros(1,Lx+Lh-n)],'fill');
title('y(n)')
xlabel('n')
grid;
pause;
end;

clear all;
% Definicion de las seales a convolucionar
Lx=2; %Longitud de x(n)
equis=[1 1]; %x(n)
if size(equis) ~= Lx
error('Error: la senhal x(n) esta mal definida')
end;
Lh=12; %Longitud de h(n)
hache=[1 4 2 3 5 3 3 4 5 7 6 9]; %h(n)
if size(hache) ~= Lh
error('Error: la senhal h(n) esta mal definida')
end;
figure(2);

% Dibujo de x(n) y h(n). Se aaden Lh ceros antes y despues
% para visualizar mejor las seales
ndib=-Lh:Lx+Lh;
subplot(211)
equisdib=[zeros(1,Lh) equis zeros(1,Lh+1)];
stem(ndib,equisdib,'fill');
title('x2(n)');
subplot(212)
hachedib=[zeros(1,Lh) hache zeros(1,Lx+1)];
stem(ndib,hachedib,'fill');
title('x1(n)');
pause;

% Bucle que realiza la convolucion
for n=0:Lx+Lh-1
% Construccion y dibujo de x(k)
xdek=[zeros(1,Lh) equis zeros(1,Lh+1)];
subplot(221)
stem(ndib,xdek,'fill');
title('x2(k)')
xlabel('k')
grid;
% Construccion y dibujo de h(n-k)
hdenmenosk=[zeros(1,n+1) hache(Lh:-1:1) zeros(1,Lx+Lh-n)];
subplot(223)
stem(ndib,hdenmenosk,'fill');
title('x1(n-k)')
xlabel('k')
grid;
% Dibujo de x(k)h(n-k)
subplot(222)
stem(ndib,xdek.*hdenmenosk,'fill');
title('x2(k)x1(n-k)')
xlabel('k')
grid;
% Obtencion y dibujo de y(n)
yden(n+1)=sum(xdek.*hdenmenosk);
subplot(224)
stem(-1:Lx+Lh,[0 yden zeros(1,Lx+Lh-n)],'fill');
title('y(n)')
xlabel('n')
grid;
pause;
end;

Primero se halla x1(n) * x2(n):



Luego, automticamente el programa hace lo mismo para x2(n) * x1(n). Seguimos
presionando enter para obtener las dos convoluciones en figuras diferentes.




Se observa que ambas convoluciones son idnticas, entonces se demuestra la
propiedad conmutativa de la convolucin.


b. x3(n) * [x1(n) + x2(n)] = x3(n) * x1(n) + x3(n) * x2(n)

Sabemos que:
x1(n) = [1 4 2 3 5 3 3 4 5 7 6 9]
x2(n) = [1 1]
x3(n) = [1 2 1]

Comenzando por el primer miembro: x3(n) * [x1(n) + x2(n)]:

x1(n) + x2(n) = [2 5 2 3 5 3 3 4 5 7 6 9]

1. Se procede a hallar x3(n) * [x1(n) + x2(n)]:

%Solucin ejercicio_6_b_1

clear all;
% Definicion de las seales a convolucionar
Lx=3; %Longitud de x(n)
equis=[1 2 1]; %x(n)
if size(equis) ~= Lx
error('Error: la senhal x(n) esta mal definida')
end;
Lh=12; %Longitud de h(n)
hache=[2 5 2 3 5 3 3 4 5 7 6 9]; %h(n)
if size(hache) ~= Lh
error('Error: la senhal h(n) esta mal definida')
end;

% Dibujo de x(n) y h(n). Se aaden Lh ceros antes y despues
% para visualizar mejor las seales
ndib=-Lh:Lx+Lh;
subplot(211)
equisdib=[zeros(1,Lh) equis zeros(1,Lh+1)];
stem(ndib,equisdib,'fill');
grid;
title('x3(n)');
subplot(212)
hachedib=[zeros(1,Lh) hache zeros(1,Lx+1)];
stem(ndib,hachedib,'fill');
title('x1(n)+x2(n)');
grid;
pause;

% Bucle que realiza la convolucion
for n=0:Lx+Lh-1
% Construccion y dibujo de x(k)
xdek=[zeros(1,Lh) equis zeros(1,Lh+1)];
subplot(221)
stem(ndib,xdek,'fill');
title('x3(k)')
xlabel('k')
grid;
% Construccion y dibujo de h(n-k)
hdenmenosk=[zeros(1,n+1) hache(Lh:-1:1) zeros(1,Lx+Lh-n)];
subplot(223)
stem(ndib,hdenmenosk,'fill');
title('x1(n-k)+x2(n-k)')
xlabel('k')
grid;
% Dibujo de x(k)h(n-k)
subplot(222)
stem(ndib,xdek.*hdenmenosk,'fill');
title('x3(k)(x1(n-k)+x2(n-k))')
xlabel('k')
grid;
% Obtencion y dibujo de y(n)
yden(n+1)=sum(xdek.*hdenmenosk);
subplot(224)
stem(-1:Lx+Lh,[0 yden zeros(1,Lx+Lh-n)],'fill');
title('y(n)')
xlabel('n')
grid;
pause;
end;

figure(2);
yden(n+1)=sum(xdek.*hdenmenosk);
stem(-1:Lx+Lh,[0 yden zeros(1,Lx+Lh-n)],'fill');
title('x3(n) * [x1(n) + x2(n)]')
xlabel('n')
grid;







2. Se procede a hallar x3(n) * x1(n) + x3(n) * x2(n):

Hay que encontrar x3(n) * x1(n):

%Solucin ejercicio_6_b_2

clear all;
% Definicion de las seales a convolucionar
Lx=3; %Longitud de x(n)
equis=[1 2 1]; %x(n)
if size(equis) ~= Lx
error('Error: la senhal x(n) esta mal definida')
end;
Lh=12; %Longitud de h(n)
hache=[1 4 2 3 5 3 3 4 5 7 6 9]; %h(n)
if size(hache) ~= Lh
error('Error: la senhal h(n) esta mal definida')
end;
% Dibujo de x(n) y h(n). Se aaden Lh ceros antes y despues
% para visualizar mejor las seales
ndib=-Lh:Lx+Lh;
subplot(211)
equisdib=[zeros(1,Lh) equis zeros(1,Lh+1)];
stem(ndib,equisdib,'fill');
grid;
title('x3(n)');
subplot(212)
hachedib=[zeros(1,Lh) hache zeros(1,Lx+1)];
stem(ndib,hachedib,'fill');
title('x1(n)');
grid;
pause;
% Bucle que realiza la convolucion
for n=0:Lx+Lh-1
% Construccion y dibujo de x(k)
xdek=[zeros(1,Lh) equis zeros(1,Lh+1)];
subplot(221)
stem(ndib,xdek,'fill');
title('x3(k)')
xlabel('k')
grid;
% Construccion y dibujo de h(n-k)
hdenmenosk=[zeros(1,n+1) hache(Lh:-1:1) zeros(1,Lx+Lh-n)];
subplot(223)
stem(ndib,hdenmenosk,'fill');
title('x1(n-k)')
xlabel('k')
grid;
% Dibujo de x(k)h(n-k)
subplot(222)
stem(ndib,xdek.*hdenmenosk,'fill');
title('x3(k)x1(n-k)')
xlabel('k')
grid;
% Obtencion y dibujo de y(n)
yden(n+1)=sum(xdek.*hdenmenosk);
subplot(224)
stem(-1:Lx+Lh,[0 yden zeros(1,Lx+Lh-n)],'fill');
title('y(n)')
xlabel('n')
grid;
pause;
end;
figure(3);
yden(n+1)=sum(xdek.*hdenmenosk);
stem(-1:Lx+Lh,[0 yden zeros(1,Lx+Lh-n)],'fill');
title('x3(n) * x1(n)')
xlabel('n')
grid;








x3(n) * x1(n) = [1 6 11 11 13 16 14 13 16 21 25 28 24 9]








Hallando x3(n) * x2(n):

%Solucin ejercicio_6_b_3
clear all;
% Definicion de las seales a convolucionar
Lx=3; %Longitud de x(n)
equis=[1 2 1]; %x(n)
if size(equis) ~= Lx
error('Error: la senhal x(n) esta mal definida')
end;
Lh=2; %Longitud de h(n)
hache=[1 1]; %h(n)
if size(hache) ~= Lh
error('Error: la senhal h(n) esta mal definida')
end;
% Dibujo de x(n) y h(n). Se aaden Lh ceros antes y despues
% para visualizar mejor las seales
ndib=-Lh:Lx+Lh;
subplot(211)
equisdib=[zeros(1,Lh) equis zeros(1,Lh+1)];
stem(ndib,equisdib,'fill');
grid;
title('x3(n)');
subplot(212)
hachedib=[zeros(1,Lh) hache zeros(1,Lx+1)];
stem(ndib,hachedib,'fill');
title('x2(n)');
grid;
pause;
% Bucle que realiza la convolucion
for n=0:Lx+Lh-1
% Construccion y dibujo de x(k)
xdek=[zeros(1,Lh) equis zeros(1,Lh+1)];
subplot(221)
stem(ndib,xdek,'fill');
title('x3(k)')
xlabel('k')
grid;
% Construccion y dibujo de h(n-k)
hdenmenosk=[zeros(1,n+1) hache(Lh:-1:1) zeros(1,Lx+Lh-n)];
subplot(223)
stem(ndib,hdenmenosk,'fill');
title('x2(n-k)')
xlabel('k')
grid;
% Dibujo de x(k)h(n-k)
subplot(222)
stem(ndib,xdek.*hdenmenosk,'fill');
title('x3(k)x2(n-k)')
xlabel('k')
grid;
% Obtencion y dibujo de y(n)
yden(n+1)=sum(xdek.*hdenmenosk);
subplot(224)
stem(-1:Lx+Lh,[0 yden zeros(1,Lx+Lh-n)],'fill');
title('y(n)')
xlabel('n')
grid;
pause;
end;
figure(3);
yden(n+1)=sum(xdek.*hdenmenosk);
stem(-1:Lx+Lh,[0 yden zeros(1,Lx+Lh-n)],'fill');
title('x3(n) * x2(n)')
xlabel('n')
grid;





x3(n) * x2(n) = [ 1 3 3 1 ]
Sumamos las convoluciones halladas:

%Solucin ejercicio_6_b_4
clear all;
n=-3:16;
x1n=[zeros(1,3) 1 6 11 11 13 16 14 13 16 21 25 28 24 9
zeros(1,3)];
x2n=[zeros(1,3) 1 3 3 1 zeros(1,13)];
xn=x1n+x2n;
figure(5);
stem(n,xn,'fill');
grid on;
title('x3(n)*x1(n) + x3(n)*x2(n)');
xlabel('n');


x3(n)*x1(n) + x3(n)*x2(n) = [ 2 9 14 12 13 16 14 13 16 21 25 28 24 9 ]




Este resultado es igual al obtenido en el primer miembro:




La propiedad distributiva ha sido demostrada.


c. [x1(n) * x2(n)] * x3(n) = x2(n) * [x1(n) * x3(n)]

4_a * x3(n) = x2(n) * 4_d

x1(n) = [1, 4, 2, 3, 5, 3, 3, 4, 5, 7, 6, 9]
x2(n) = [1, 1]
x3(n) = [1, 2, 1]
Del ejercicio _4_a: x1(n) * x2(n) = [1, 5, 6, 5, 8, 8, 6, 7, 9, 12, 13, 15, 9]
Del ejercicio_4_b: x1(n) * x3(n) = [1, 6, 11, 11, 13, 16, 14, 13, 16, 21, 25, 28, 24, 9]

Resolviendo el primer miembro: [x1(n) * x2(n)] * x3(n)

%Solucin ejercicio_6_c_1

clear all;
% Definicion de las seales a convolucionar
Lx=13; %Longitud de x(n)
equis=[1 5 6 5 8 8 6 7 9 12 13 15 9]; %x(n)
if size(equis) ~= Lx
error('Error: la senhal x(n) esta mal definida')
end;
Lh=3; %Longitud de h(n)
hache=[1 2 1]; %h(n)
if size(hache) ~= Lh
error('Error: la senhal h(n) esta mal definida')
end;

% Dibujo de x(n) y h(n). Se aaden Lh ceros antes y despues
% para visualizar mejor las seales
ndib=-Lh:Lx+Lh;
subplot(211)
equisdib=[zeros(1,Lh) equis zeros(1,Lh+1)];
stem(ndib,equisdib,'fill');
title('x(n)');
subplot(212)
hachedib=[zeros(1,Lh) hache zeros(1,Lx+1)];
stem(ndib,hachedib,'fill');
title('h(n)');
pause;
% Bucle que realiza la convolucion
for n=0:Lx+Lh-1
% Construccion y dibujo de x(k)
xdek=[zeros(1,Lh) equis zeros(1,Lh+1)];
subplot(221)
stem(ndib,xdek,'fill');
title('x(k)')
xlabel('k')
grid;
% Construccion y dibujo de h(n-k)
hdenmenosk=[zeros(1,n+1) hache(Lh:-1:1) zeros(1,Lx+Lh-n)];
subplot(223)
stem(ndib,hdenmenosk,'fill');
title('h(n-k)')
xlabel('k')
grid;
% Dibujo de x(k)h(n-k)
subplot(222)
stem(ndib,xdek.*hdenmenosk,'fill');
title('x(k)h(n-k)')
xlabel('k')
grid;
% Obtencion y dibujo de y(n)
yden(n+1)=sum(xdek.*hdenmenosk);
subplot(224)
stem(-1:Lx+Lh,[0 yden zeros(1,Lx+Lh-n)],'fill');
title('y(n)')
xlabel('n')
grid;
pause;
end;













Convolucin del primer miembro




Resolviendo el segundo miembro: x2(n) * [x1(n) * x3(n)]

%Solucin ejercicio_6_c_2
clear all;
% Definicion de las seales a convolucionar
Lx=2; %Longitud de x(n)
equis=[1 1]; %x(n)
if size(equis) ~= Lx
error('Error: la senhal x(n) esta mal definida')
end;
Lh=14; %Longitud de h(n)
hache=[1 6 11 11 13 16 14 13 16 21 25 28 24 9]; %h(n)
if size(hache) ~= Lh
error('Error: la senhal h(n) esta mal definida')
end;
% Dibujo de x(n) y h(n). Se aaden Lh ceros antes y despues
% para visualizar mejor las seales
ndib=-Lh:Lx+Lh;
subplot(211)
equisdib=[zeros(1,Lh) equis zeros(1,Lh+1)];
stem(ndib,equisdib,'fill');
title('x(n)');
subplot(212)
hachedib=[zeros(1,Lh) hache zeros(1,Lx+1)];
stem(ndib,hachedib,'fill');
title('h(n)');
pause;
% Bucle que realiza la convolucion
for n=0:Lx+Lh-1
% Construccion y dibujo de x(k)
xdek=[zeros(1,Lh) equis zeros(1,Lh+1)];
subplot(221)
stem(ndib,xdek,'fill');
title('x(k)')
xlabel('k')
grid;
% Construccion y dibujo de h(n-k)
hdenmenosk=[zeros(1,n+1) hache(Lh:-1:1) zeros(1,Lx+Lh-n)];
subplot(223)
stem(ndib,hdenmenosk,'fill');
title('h(n-k)')
xlabel('k')
grid;
% Dibujo de x(k)h(n-k)
subplot(222)
stem(ndib,xdek.*hdenmenosk,'fill');
title('x(k)h(n-k)')
xlabel('k')
grid;
% Obtencion y dibujo de y(n)
yden(n+1)=sum(xdek.*hdenmenosk);
subplot(224)
stem(-1:Lx+Lh,[0 yden zeros(1,Lx+Lh-n)],'fill');
title('y(n)')
xlabel('n')
grid;
pause;
end;
figure(5);
stem(-1:Lx+Lh,[0 yden zeros(1,Lx+Lh-n)],'fill');
title('y(n)')
xlabel('n')
grid;






















Convolucin del Segundo Miembro



La propiedad asociativa ha sido demostrada


IV. CONCLUSIONES Y OBSERVACIONES:

La operacin de convolucin puede establecerse sobre un cdigo en Matlab,
haciendo posible su modificacin para diversas seales a convolucionar.

En el programa convolucin.m se debe establecer la duracin de cada seal
ingresada, de lo contrario nos muestra un mensaje de error.

Es posible visualizar cada paso en el proceso de convolucin mediante un bucle
diseado para tal fin.

Con el uso de Matlab es posible comparar mejor y de manera rpida las
relaciones entre diversas convoluciones.

Con el programa convolucin.m es posible demostrar las propiedades de la
convolucin, slo basta ingresar las seales y verificar los resultados.





V. BIBLIOGRAFA O REFERENCIAS UTILIZADAS EN EL
DESARROLLO DE LA PRCTICA

A. Ambardar - Procesamiento de Seales Analgicas y Digitales
Alan V. Oppenheim & Alan S. Willsky Seales y Sistemas



VI. ANEXO

Programa convolucion.m

%*********************************************************************
%
% Nombre: convolucion.m
%
% Objetivo: calcula la convolucin de dos seales paso
% a paso visualizando los resultados intermedios
%
%
%*********************************************************************

clear all;
% Definicion de las seales a convolucionar
Lx=48; %Longitud de x(n)
equis=sin(pi*(0:Lx-1)/12 + pi/4); %x(n)
if size(equis) ~= Lx
error('Error: la senhal x(n) esta mal definida')
end;

Lh=15; %Longitud de h(n)
hache=(7/8).^(0:Lh-1); %h(n)
if size(hache) ~= Lh
error('Error: la senhal h(n) esta mal definida')
end;

% Dibujo de x(n) y h(n). Se aaden Lh ceros antes y despues
% para visualizar mejor las seales
ndib=-Lh:Lx+Lh;
subplot(211)
equisdib=[zeros(1,Lh) equis zeros(1,Lh+1)];
stem(ndib,equisdib);
title('x(n)');
subplot(212)
hachedib=[zeros(1,Lh) hache zeros(1,Lx+1)];
stem(ndib,hachedib);
title('h(n)');
pause;


% Bucle que realiza la convolucion
for n=0:Lx+Lh-1
% Construccion y dibujo de x(k)
xdek=[zeros(1,Lh) equis zeros(1,Lh+1)];
subplot(221)
stem(ndib,xdek);
title('x(k)')
xlabel('k')
grid;

% Construccion y dibujo de h(n-k)
hdenmenosk=[zeros(1,n+1) hache(Lh:-1:1) zeros(1,Lx+Lh-n)];
subplot(223)
stem(ndib,hdenmenosk);
title('h(n-k)')
xlabel('k')
grid;

% Dibujo de x(k)h(n-k)
subplot(222)
stem(ndib,xdek.*hdenmenosk);
title('x(k)h(n-k)')
xlabel('k')
grid;

% Obtencion y dibujo de y(n)
yden(n+1)=sum(xdek.*hdenmenosk);
subplot(224)
stem(-1:Lx+Lh,[0 yden zeros(1,Lx+Lh-n)]);
title('y(n)')
xlabel('n')
grid;
pause;
end;

También podría gustarte