Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- load('lab03.mat');
- %sound(m1,fs);
- N = length(m1);
- Ts = 1/fs;
- t=(0:N-1)*Ts;
- f=linspace(0,fs/2, (N/2) + 1);
- nGraficos = 8;
- % m1 e s1
- c1 = cos(2*pi*12000*t);
- s1 = m1.*c1;
- subplot(nGraficos,1,1);
- plot(t, m1);
- title('m1(t)');
- grid on;
- xlim([0.72, 0.74]);
- subplot(nGraficos,1,2);
- plot(t, s1);
- title('s1(t)');
- grid on;
- xlim([0.72, 0.74]);
- % m2 e s2
- c2 = sin(2*pi*12000*t);
- s2 = m2.*c2;
- subplot(nGraficos,1,3);
- plot(t, m2);
- title('m2(t)');
- grid on;
- xlim([0.72, 0.74]);
- subplot(nGraficos,1,4);
- plot(t, s2);
- title('s2(t)');
- grid on;
- xlim([0.72, 0.74]);
- % M1 e S1
- M1 = fftlab(m1);
- subplot(nGraficos,1,5);
- plot(f, abs(M1));
- title('M1(f)');
- grid on;
- xlim([0, 18000]);
- S1 = fftlab(s1);
- subplot(nGraficos,1,6);
- plot(f, abs(S1));
- title('S1(f)');
- grid on;
- xlim([0, 18000]);
- % M2 e S2
- M2 = fftlab(m2);
- subplot(nGraficos,1,7);
- plot(f, abs(M2));
- title('M2(f)');
- grid on;
- xlim([0, 18000]);
- S2 = fftlab(s2);
- subplot(nGraficos,1,8);
- plot(f, abs(S2));
- title('S2(f)');
- grid on;
- xlim([0, 18000]);
- % exercicio 2
- figure(2);
- nGraficosEx2 = 5;
- s = s1 + s2;
- v1 = s*2.*c1;
- v2 = s*2.*c2;
- fcorte = 5500/(fs/2);
- h = fir1(2000,fcorte);
- [H, fh] = freqz(h,1,N/2+1,fs/1000) ;
- H = abs(H);
- vo1 = filter(h,1,v1);
- vo2 = filter(h,1,v2);
- S = fftlab(s);
- subplot(nGraficosEx2,1,1);
- plot(f, abs(S));
- title('S(f)');
- grid on;
- xlim([0, 30000]);
- V1 = fftlab(v1);
- subplot(nGraficosEx2,1,2);
- plot(f, abs(V1));
- title('V1(f)');
- grid on;
- xlim([0, 30000]);
- V2 = fftlab(v2);
- subplot(nGraficosEx2,1,3);
- plot(f, abs(V2));
- title('V2(f)');
- grid on;
- xlim([0, 30000]);
- Vo1 = fftlab(vo1);
- subplot(nGraficosEx2,1,4);
- plot(f, abs(Vo1));
- title('Vo1(f)');
- grid on;
- xlim([0, 30000]);
- Vo2 = fftlab(vo2);
- subplot(nGraficosEx2,1,5);
- plot(f, abs(Vo2));
- title('Vo2(f)');
- grid on;
- xlim([0, 30000]);
- sound(m1, fs);
- pause(3);
- sound(vo1, fs);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement