PLEASE ANSWER QUESTION #2
Design an FIR band-pass filter with cutoff frequencies of π/ 4 and π/ 6 . The filter’s impulse response should have 81 samples (i.e. N = 81). Use a Blackman filter window.
(a) Plot the filter’s impulse response
(b) Plot the magnitude of the filter’s frequency response, in dB. (i.e. 20 log(|H(e jω)|))
(c) Print out the MATLAB code used in the filter design
2. Use the filter designed in #1 to filter a random input signal of 128 samples. (i.e. use x = randn([1 128]) to generate the random signal)
(a) Plot the input and output signals, x[n], and y[n].
(b) Plot the magnitude of the FFT’s of x[n] and y[n], in dB. (i.e. 20 log(|X(e jω)|)).
(c) Print out the MATLAB code used to generate these items.
NOTE: Assuming filter designing part is done and we have filter coefficients [num,den] saved in the Matlab Workspace.
Code:
L=128;
Fs=1;
Ts=1/Fs;
t=Ts:Ts:L*Ts;
x=randn(1,L);
subplot(2,1,1)
plot(t,x)
title('Input')
xlim([0 Ts*L])
y=filter(num,den,x);
subplot(2,1,2)
plot(t,y)
title('Output')
xlim([0 Ts*L])
%% Frequency response:
dF = Fs/L;
f = -Fs/2:dF:Fs/2-dF;
X=fftshift(fft(x));
Y=fftshift(fft(y));
figure();
subplot(2,1,1)
plot(f,20*log10(abs(X)/L));
title('Magnitude Response of Input')
subplot(2,1,2)
plot(f,20*log10(abs(Y)/L));
title('Magnitude Response of Output')
Output:
Get Answers For Free
Most questions answered within 1 hours.