Practica 3: Convolucion: Ejercicios 1. Determinar y Plotear Las Siguientes Secuencias
Practica 3: Convolucion: Ejercicios 1. Determinar y Plotear Las Siguientes Secuencias
PRACTICA 3: CONVOLUCION
EJERCICIOS
>> xlabel('n');ylabel('x2(n)');grid
2. Convolucion
a) y(n) = x(n)*h(n)
𝑥(𝑛) = {1,1,1,1} −5 ≤𝑛 ≤ 3
x=[1 1 1 1 1 1 1 1 1];
n1=-5:3;
subplot(3,1,1);stem(n1,x)
h=[7 6 5 4 3 2];
n2= -1:4
subplot(3,1,2);stem(n2,h)
y = conv(x,h)
subplot(3,1,3);stem(y)
b) y(n) = x(n)*h(n)
1
𝑥(𝑛) = { 𝑛[𝑢(𝑛) − 𝑢(𝑛 − 7]}
3
>> n=[-20:20];
>> x = 1/3*n.*(escalon(0,-20,20) - escalon(7,-20,20));
>> h = escalon(-2,-20,20)-escalon(3,-20,20);
>> y = conv(x,h)
>> stem(y)
EJERCICIOS
1. Descomponer las secuencias en sus componentes pares e impares
20
x(n)
10
0
-10 -8 -6 -4 -2 0 2 4 6 8 10
n
par
20
xe(n)
10
0
-10 -8 -6 -4 -2 0 2 4 6 8 10
n
impar
10
xo(n)
-10
-10 -8 -6 -4 -2 0 2 4 6 8 10
n
𝑥2 (𝑛) = 5𝑥(5 + 𝑛) + 4𝑥(𝑛 + 4) + 3𝑥(𝑛)
n=-3:3;x=[2 -1 6 9 -5 8 1];
[x21,n21]=signo(x,n,-5);[x22,n22]=signo(x,n,-4);
[x23,n23]=signo(x,n,0);
[x21,n21]=suma(5*x21,n21,4*x22,n22);
[x2,n2]=suma(x21,n21,3*x23,n23);
[xe,xo,m] = parimpar(x2,n2);
subplot(1,1,1)
subplot(3,1,1); stem(n2,x2);
xlabel('n'); ylabel('x(n)'); axis([-10,10,0,20])
subplot(3,1,2); stem(m,xe); title('par')
xlabel('n'); ylabel('xe(n)'); axis([-10,10,0,20])
subplot(3,1,3); stem(m,xo); title('impar')
xlabel('n'); ylabel('xo(n)'); axis([-10,10,-10,10])
20
x(n)
10
0
-10 -8 -6 -4 -2 0 2 4 6 8 10
n
par
xe(n) 20
10
0
-10 -8 -6 -4 -2 0 2 4 6 8 10
n
impar
10
xo(n)
-10
-10 -8 -6 -4 -2 0 2 4 6 8 10
n
𝑥3 (𝑛) = 𝑥(𝑛 + 4)𝑥(𝑛 − 1) + 𝑥(2 − 𝑛)𝑥(𝑛)
n=-3:3;x=[2 -1 6 9 -5 8 1];
[x31,n31]=signo(x,n,-4);[x32,n32]=signo(x,n,1);
[x33,n33]=signo(x,n,0);
[x34,n34]=signo1(x,n);[x34,n34]=signo(x34,n34,-2);
[x31,n31]=mul(x31,n31,x32,n32);[x33,n33]=mul(x33,n33,x34,n34);
[x3,n3]=suma(x31,n31,x33,n33);
[xe,xo,m] = parimpar(x3,n3);
subplot(1,1,1)
subplot(3,1,1); stem(n3,x3);
xlabel('n'); ylabel('x(n)'); axis([-10,10,0,20])
subplot(3,1,2); stem(m,xe); title('par')
xlabel('n'); ylabel('xe(n)'); axis([-10,10,0,20])
subplot(3,1,3); stem(m,xo); title('impar')
xlabel('n'); ylabel('xo(n)'); axis([-10,10,-10,10])
20
x(n)
10
0
-10 -8 -6 -4 -2 0 2 4 6 8 10
n
par
20
xe(n)
10
0
-10 -8 -6 -4 -2 0 2 4 6 8 10
n
impar
10
xo(n)
-10
-10 -8 -6 -4 -2 0 2 4 6 8 10
n
[x41,n41]=mul(6*x41,n41,x42,n42);
[x4,n4]=suma(x41,n41,-1*x43,n43);
[xe,xo,m] = parimpar(x4,n4);
subplot(1,1,1)
subplot(3,1,1); stem(n4,x4);
xlabel('n'); ylabel('x(n)'); axis([-10,10,0,20])
subplot(3,1,2); stem(m,xe); title('par')
xlabel('n'); ylabel('xe(n)'); axis([-10,10,0,20])
subplot(3,1,3); stem(m,xo); title('impar')
xlabel('n'); ylabel('xo(n)'); axis([-10,10,-10,10])
20
x(n)
10
0
-10 -8 -6 -4 -2 0 2 4 6 8 10
n
par
20
xe(n)
10
0
-10 -8 -6 -4 -2 0 2 4 6 8 10
n
impar
10
xo(n)
-10
-10 -8 -6 -4 -2 0 2 4 6 8 10
n
2. Sea la señal 𝑥(𝑡) = cos(2𝜋𝑓𝑜 𝑡 + 𝜑), y la señal discreta generada a partir de ella xd (n)
= x (t)|t=nTs .
Graficar 20 ms de x (n), para f0 = 100, 225, 350, 475Hz, considerando que Fs=1/Ts = 8000Hz,
2000Hz, 1000Hz, 500Hz
% 4 graficos con f=100
cont=0;
for f=[100]; %225 350 475
fso=1e6;
No= fso*20e-3;
to=(0:No-1)/fso;
xo=cos(2*pi*f*to);
for fs=[8000 2000 1000 500];
N=fs*1;
t=(0:N-1)/fs;
x=cos(2*pi*f*t);
cont=cont+1;
subplot(2,2,cont);
plot(to*1e3,xo,'k',t*1e3,x,'b-o');axis([0,20,-1,1]);
title(sprintf('frec. señal:%iHz frec. muestreo:%iHz periodo
muestreo: %fms',f,fs,1e3/fs))
legend('Señal original','Señal
muestreada');xlabel('milisegundos');% pause;
end
end
Para f = 100 Hz
frec. señal:100Hz frec. muestreo:8000Hz periodo muestreo: 0.125000ms frec. señal:100Hz frec. muestreo:1000Hz periodo muestreo: 1.000000ms
1 1
Señal original Señal original
0.8 Señal muestreada 0.8 Señal muestreada
0.6 0.6
0.4 0.4
0.2 0.2
0 0
-0.2 -0.2
-0.4 -0.4
-0.6 -0.6
-0.8 -0.8
-1 -1
0 2 4 6 8 10 12 14 16 18 20 0 2 4 6 8 10 12 14 16 18 20
milisegundos milisegundos
frec. señal:100Hz frec. muestreo:2000Hz periodo muestreo: 0.500000ms frec. señal:100Hz frec. muestreo:500Hz periodo muestreo: 2.000000ms
1 1
Señal original Señal original
0.8 Señal muestreada 0.8 Señal muestreada
0.6 0.6
0.4 0.4
0.2 0.2
0 0
-0.2 -0.2
-0.4 -0.4
-0.6 -0.6
-0.8 -0.8
-1 -1
0 2 4 6 8 10 12 14 16 18 20 0 2 4 6 8 10 12 14 16 18 20
milisegundos milisegundos
Pa
% 4 graficos con f=225
cont=0;
for f=[225]; %225 350 475
fso=1e6;
No= fso*20e-3;
to=(0:No-1)/fso;
xo=cos(2*pi*f*to);
for fs=[8000 2000 1000 500];
N=fs*1;
t=(0:N-1)/fs;
x=cos(2*pi*f*t);
cont=cont+1;
subplot(2,2,cont);
plot(to*1e3,xo,'k',t*1e3,x,'b-o');axis([0,20,-1,1]);
title(sprintf('frec. señal:%iHz frec. muestreo:%iHz periodo
muestreo: %fms',f,fs,1e3/fs))
legend('Señal original','Señal
muestreada');xlabel('milisegundos');% pause;
end
end
N=fs*1;
t=(0:N-1)/fs;
x=cos(2*pi*f*t);
cont=cont+1;
subplot(2,2,cont);
plot(to*1e3,xo,'k',t*1e3,x,'b-o');axis([0,20,-1,1]);
title(sprintf('frec. señal:%iHz frec. muestreo:%iHz periodo
muestreo: %fms',f,fs,1e3/fs))
legend('Señal original','Señal
muestreada');xlabel('milisegundos');% pause;
end
end
para f = 225 Hz
frec. señal:225Hz frec. muestreo:8000Hz periodo muestreo: 0.125000ms frec. señal:225Hz frec. muestreo:2000Hz periodo muestreo: 0.500000ms
1 1
Señal original Señal original
0.8 Señal muestreada 0.8 Señal muestreada
0.6 0.6
0.4 0.4
0.2 0.2
0 0
-0.2 -0.2
-0.4 -0.4
-0.6 -0.6
-0.8 -0.8
-1 -1
0 2 4 6 8 10 12 14 16 18 20 0 2 4 6 8 10 12 14 16 18 20
milisegundos milisegundos
frec. señal:225Hz frec. muestreo:1000Hz periodo muestreo: 1.000000ms frec. señal:225Hz frec. muestreo:500Hz periodo muestreo: 2.000000ms
1 1
Señal original Señal original
0.8 Señal muestreada 0.8 Señal muestreada
0.6 0.6
0.4 0.4
0.2 0.2
0 0
-0.2 -0.2
-0.4 -0.4
-0.6 -0.6
-0.8 -0.8
-1 -1
0 2 4 6 8 10 12 14 16 18 20 0 2 4 6 8 10 12 14 16 18 20
milisegundos milisegundos
Para f = 350 Hz
frec. señal:350Hz frec. muestreo:8000Hz periodo muestreo: 0.125000ms frec. señal:350Hz frec. muestreo:1000Hz periodo muestreo: 1.000000ms
1 1
Señal original Señal original
0.8 Señal muestreada 0.8 Señal muestreada
0.6 0.6
0.4 0.4
0.2 0.2
0 0
-0.2 -0.2
-0.4 -0.4
-0.6 -0.6
-0.8 -0.8
-1 -1
0 2 4 6 8 10 12 14 16 18 20 0 2 4 6 8 10 12 14 16 18 20
milisegundos milisegundos
frec. señal:350Hz frec. muestreo:2000Hz periodo muestreo: 0.500000ms frec. señal:350Hz frec. muestreo:500Hz periodo muestreo: 2.000000ms
1 1
Señal original Señal original
0.8 Señal muestreada 0.8 Señal muestreada
0.6 0.6
0.4 0.4
0.2 0.2
0 0
-0.2 -0.2
-0.4 -0.4
-0.6 -0.6
-0.8 -0.8
-1 -1
0 2 4 6 8 10 12 14 16 18 20 0 2 4 6 8 10 12 14 16 18 20
milisegundos milisegundos
Para f= 475 Hz
0.6
0.4
0.2
-0.2
-0.4
-0.6
-0.8
-1
0 2 4 6 8 10 12 14 16 18 20
milisegundos
0.6
0.4
0.2
-0.2
-0.4
-0.6
-0.8
-1
0 2 4 6 8 10 12 14 16 18 20
milisegundos
0.6
0.4
0.2
-0.2
-0.4
-0.6
-0.8
-1
0 2 4 6 8 10 12 14 16 18 20
milisegundos
0.6
0.4
0.2
-0.2
-0.4
-0.6
-0.8
-1
0 2 4 6 8 10 12 14 16 18 20
milisegundos
EJERCICIOS PROPUESTOS
1. Para cada función determinar DTFT 𝑋(𝑒 𝑗𝑤 ). Plotear la magnitud y ángulo de 𝑋(𝑒 𝑗𝑤 )
n=0:10;
x=((n.*(0.9.^n)).*(escalon(0,0,10)-escalon(50,0,10)));
k = -200:200; w=(pi/100)*k;
X =x*(exp(j*pi/100)).^(n'*k); %DTFT usando matrix-vector
magX = abs(X);angX=angle(X);
subplot(3,2,1);plot(w/pi,magX);grid
xlabel('Frecuencia');title('Magnitud');
subplot(3,2,2);plot(w/pi,angX/pi);grid
xlabel('Frecuencia');title('angulo');
n=0:6;
x=[ 𝟒, 3,2,1,2,3,4];
k = -200:200; w=(pi/100)*k;
X =x*(exp(j*pi/100)).^(n'*k); %DTFT usando matrix-vector
magX = abs(X);angX=angle(X);
subplot(3,2,3);plot(w/pi,magX);grid
xlabel('Frecuencia');title('Magnitud');
subplot(3,2,4);plot(w/pi,angX/pi);grid
xlabel('Frecuencia');title('angulo');
n=0:8;
x=[𝟒, 3,2,1,0, −1, −2, −3, −4];
k = -200:200; w=(pi/100)*k;
X =x*(exp(j*pi/100)).^(n'*k); %DTFT usando matrix-vector
magX = abs(X);angX=angle(X);
subplot(3,2,5);plot(w/pi,magX);grid
xlabel('Frecuencia');title('Magnitud');
subplot(3,2,6);plot(w/pi,angX/pi);grid
xlabel('Frecuencia');title('angulo');
2. Determinar y analizar la DTFT para cada una de las secuencias. Plotear magnitud y
angulo usando Matlab (comentar las graficas ploteadas)
n=0:10;
x=((3*((0.9).^3)).*(escalon(0,0,10)));
k = -200:200; w=(pi/100)*k;
X =x*(exp(-j*pi/100)).^(n'*k); %DTFT usando matrix-vector
magX = abs(X);angX=angle(X);
subplot(3,2,1);plot(w/pi,magX);grid
xlabel('Frecuencia');title('Magnitud');
subplot(3,2,2);plot(w/pi,angX/pi);grid
xlabel('Frecuencia');title('angulo');
magX = abs(X);angX=angle(X);
subplot(2,2,1);plot(w/pi,magX);grid
xlabel('Frecuencia');title('Magnitud');
subplot(2,2,2);plot(w/pi,angX/pi);grid
xlabel('Frecuencia');title('angulo');