Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Daniel Castillo Gamez

Practica

F = [100 200 300 400] * 1e3;


Fc = 15e3;
Fp = Fc - Fc * 0.2;
Fs = Fc + Fc * 0.2;
fmax = max(F);
fs = 20 * fmax;
Wp = Fp / (fs/2);
Ws = Fs / (fs/2);
% Design a digital filter
d_equiripple = designfilt('lowpassfir', ...
'FilterOrder',50,'PassbandFrequency',120000, ...
'StopbandFrequency',180000,'SampleRate',fs);

% Visualize magnitude and phase responses


freqz(d_equiripple.Coefficients,1,[],fs)

% Design a digital filter


d_kaiser = designfilt('lowpassfir', ...
'PassbandFrequency',120000,'StopbandFrequency',180000, ...
'PassbandRipple',1,'StopbandAttenuation',60, ...
'SampleRate',fs,'DesignMethod','kaiserwin');

% Visualize magnitude and phase responses

1
freqz(d_kaiser.Coefficients,1,[],fs)

% Get filter information


info(d_kaiser)

ans = 20×32 char array


'FIR Digital Filter (real) '
'------------------------- '
'Filter Length : 494 '
'Stable : Yes '
'Linear Phase : Yes (Type 2) '
' '
'Design Method Information '
'Design Algorithm : Kaiser window'
' '
'Design Options '
'Minimum Order : any '
'Scale Passband : true '
' '
'Design Specifications '
'Sample Rate : 8 MHz '
'Response : Lowpass '
'Stopband Atten. : 60 dB '
'Passband Edge : 120 kHz '
'Passband Ripple : 1 dB '
'Stopband Edge : 180 kHz '

t = 0:1/fs:100/fmax;
senal = 2 * sin(2*pi*F(1)*t) + 2 * sin(2*pi*F(2)*t) + 2 * sin(2*pi*F(3)*t) +
2 * sin(2*pi*F(4)*t);
senal_resultante = 2 * sin(2*pi*F(1)*t);

2
senal_filtrada_equiripple = filter(d_equiripple, senal);
senal_filtrada_kaiser = filter(d_kaiser, senal);
figure;
subplot(3,1,1);
plot(t, senal);
title('señal normal');
subplot(3,1,2);
plot(t, senal_filtrada_equiripple, '+k', t, senal_resultante, 'r');
title('señal filtrada equiripple y señal filtrada esperada');
subplot(3,1,3);
plot(t, senal_filtrada_kaiser, '+k', t, senal_resultante, 'g')
title('señal filtrada de kaiser y señal filtrada esperada');

You might also like