Você está na página 1de 6

Table of Contents

Laboratório 8 ...................................................................................................................... 1
Parte 1 .............................................................................................................................. 1
Parte 2 .............................................................................................................................. 3
Parte 3: ............................................................................................................................. 4

Laboratório 8
Alunos: * Denner Paganoti: GRR20156016 * Vinicius Scheibel: GRR20155230 * Willer Siqueira:
GRR20159242

clear
clc

Parte 1
%escutando o áudio e traçando o gráfico de módulo na frequência
[xn Fs]=audioread('som.wav');

xn_f=fft(xn);

for k=0:length(xn_f)-1
wk = 2*pi*k/length(xn_f);
if wk > pi
wk = wk - 2*pi;
end
freq(k+1) = (wk/(2*pi))*Fs;
end

figure(1)
hold on
subplot(3,1,1)
plot(freq,abs(xn_f))
axis([-0.5e4 0.5e4 0 4000]);
title('Sinal sem interferência')

%escutando e plotando o sinal com interferência


[xn_i Fs_i]=audioread('sominterf.wav');

xn_fi = fft(xn_i);

for k_i=0:length(xn_fi)-1
wk_i = 2*pi*k_i/length(xn_fi);
if wk_i > pi
wk_i = wk_i - 2*pi;
end
freq_i(k_i+1) = (wk_i/(2*pi))*Fs_i;
end

subplot(3,1,2)

1
plot(freq_i,abs(xn_fi))
axis([-0.5e4 0.5e4 0 4000]);
title('Sinal com interferência')

%gerando os sinais x1, x2 e x3 e somando-os com o sinal de áudio


original
for n=0:length(xn)-1
x11(n+1)=(1/4)*cos(2*pi*(1100/Fs)*n);
x21(n+1)=(1/2)*cos(2*pi*(1300/Fs)*n);
x31(n+1)=(1/4)*cos(2*pi*(1900/Fs)*n);
xn_intd(n+1)=xn(n+1)+x11(n+1)+x21(n+1)+x31(n+1);
end

xn_intdf=fft(xn_intd);

for k_intdf=0:length(xn_intdf)-1
wk_intdf = 2*pi*k_intdf/length(xn_intdf);
if wk_intdf > pi
wk_intdf = wk_intdf - 2*pi;
end
freq_intdf(k_intdf+1) = (wk_intdf/(2*pi))*Fs;
end

subplot(3,1,3)
plot(freq_intdf, abs(xn_intdf))
axis([-0.5e4 0.5e4 0 30000]);
title('Sinal com interferências somadas')

sound(abs(xn_intdf),Fs)

2
Parte 2
%Calculando os sinais x1 e x2 e plotando a diferença de fase entre
eles

Fs = 8000;
N = 200;

for k=0:N-1
wk = 2*pi*k/N;
if wk > pi
wk = wk - 2*pi;
end
f(k+1) = (wk/(2*pi))*Fs;
x1(k+1)=cos(wk*k+pi/3);
x2(k+1)=cos(wk*k+pi/6);
end

figure(2)
hold on
subplot(3,1,1)
stem(f,angle(x1))
title('Sinal 1 = cos(w*k+pi/3)')
subplot(3,1,2)
stem(f,angle(x2))

3
title('Sinal 1 = cos(w*k+pi/6)')
subplot(3,1,3)
stem(f,abs(angle(x1)-angle(x2)))
title('Diferença de fase entre os sinais')

Parte 3:
%Implementando os sinal x(t) e o escutando
Fex31=1000;
Fex32=1500;
Fex33=2000;
Fsex3=8000;
nex3=0;
for i=0:48000-1
xnex3(i+1)=cos(2*pi*(Fex31/Fsex3)*nex3)+cos(2*pi*(Fex32/
Fsex3)*nex3)+cos(2*pi*(Fex33/Fsex3)*nex3);
nex3=nex3+(1/Fsex3);
end

xnex3_fft=fft(xnex3);
sound(abs(xnex3), Fsex3)

for qex3=0:length(xnex3)-1
wkex3 = 2*pi*qex3/(length(xnex3)-1);
if wkex3 > pi
wkex3 = wkex3 - 2*pi;

4
end
fex3(qex3+1) = (wkex3/(2*pi))*Fsex3;
end

%Plotando o sinal x(t)


figure(3)
hold on
subplot(3,1,1)
plot(fex3, abs(xnex3_fft))
title('Sinal x(t)')
axis([-20 20 0 50000]);

%Implementando as formas de onda x1, x2 e x3


for i=0:48000-1
if i<=15999
yex3(i+1)=cos(2*pi*(Fex31/Fsex3)*nex3);
elseif (i>15599 && i<=23999)
yex3(i+1)=cos(2*pi*(Fex32/Fsex3)*nex3);
else
yex3(i+1)=cos(2*pi*(Fex33/Fsex3)*nex3);
end
end
%Escutando as formas de onda e plotando-as
yex3_fft=fft(yex3);
sound(abs(yex3_fft),Fsex3)

for qex3=0:length(xnex3)-1
wykex3 = 2*pi*qex3/(length(yex3)-1);
if wykex3 > pi
wykex3 = wykex3 - 2*pi;
end
fyex3(qex3+1) = (wykex3/(2*pi))*Fsex3;
end
subplot(3,1,2)
plot(fyex3, abs(yex3_fft))
axis([-20 20 0 40000]);
title('Sinais x1, x2 e x3 somados')

subplot(3,1,3)
plot(fex3, abs(xnex3_fft),'b',fyex3, abs(yex3_fft), 'r')
axis([-20 20 0 50000]);
title('Sinais sobrepostos')

%Percebe-se que no sinal 2 ocorre leakage, havendo um espalhamento de


%frequências em torno da origem, o que não ocorre no caso 1.

5
Published with MATLAB® R2016a

Você também pode gostar