Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

3.2 Nulling Filters for Frequency Rejectioin Nulling filters are filters that co

ID: 2249950 • Letter: 3

Question

3.2 Nulling Filters for Frequency Rejectioin Nulling filters are filters that completely eliminate some frequency component. These can be useful to remove jamming signals or to eliminate unwanted interference, such as 60 Hz harmonic hum from power lines. The simplest possible nulling filter has three coefficients and has the form where w! is the nulling frequency, i.e., H(ja ) will be equal to zero at w-wi. For example, a filter designed to completely eliminate signals of the form Acos(0.5n would have the following coefficients bo = 1, b1 =-2 cos(0.5m) = 0, b2 = 1 In order to remove more than one frequency, we may form a cascade of two or more nullling filters. Consider, for example the following two filters w[n] = n] _ 2cos(wi)x[n-1] +x[n-2] y[n] = w[n]-2cos(W2)w[n-11+ w[n-2] where the first filter removes sinusoids with a frequency u (FIR FILTER-1 ) (FIR FILTER-2) and the second removes sinusoids with a frequency 2. The cascade of these two filters is illustrated in the following figure r[n yIn] FIRn Filter #1 FIR Filter #2 Figure 1: Cascade of two FIR nulling filters.

Explanation / Answer

% Generate the following windows with the length of each window should be 21.
% (a) Rectangular, (b) Hanning, (c) Hamming and (d) Kaiser window
% Also sketch the Frequency (magnitude) responses of the above windows.
%
% Solution                                                                                                                                  

clear all; close all; clc;

% Rect window
N=21;
Rw=boxcar(N);
[h,omega1]=freqz(Rw,1,256);% frequency response of the window
mag1=20*log10(abs(h)); %DB magnitude

% hanning window
Hnw=hanning(N);
[h,omega2]=freqz(Hnw,1,256);% frequency response of the window
mag2=20*log10(abs(h)); %DB magnitude

% hamming window
Hmw=hamming(N);
[h,omega3]=freqz(Hmw,1,256);% frequency response of the window
mag3=20*log10(abs(h)); %DB magnitude

%kaisar
alpha = 5;
kw=kaiser(N,alpha);
[h,omega4]=freqz(kw,1,256);% frequency response of the window
mag4=20*log10(abs(h)); %DB magnitude

%-------------------Time domain plots -----------------------------

n = 0: N-1;
figure()
subplot(2,2,1); stem(n, Rw,'r','fill','LineWidth',1.5); grid
xlabel('Time index ------>');
ylabel('Magnitude--->');
title('Rectangular Window');
axis([-1 N -0.05 1.2]);

subplot(2,2,2); stem(n, Hnw,'b','fill','LineWidth',1.5); grid
xlabel('Time index ------>');
ylabel('Magnitude--->');
title('Hanning Window');
axis([-1 N -0.05 1.2]);


subplot(2,2,3); stem(n, Hmw,'k','fill','LineWidth',1.5); grid
xlabel('Time index ------>');
ylabel('Magnitude--->');
title('Hamming Window');
axis([-1 N -0.05 1.2]);


subplot(2,2,4); stem(n, kw,'m','fill','LineWidth',1.5); grid
xlabel('Time index ------>');
ylabel('Magnitude--->');
title('Kaiser Window');
axis([-1 N -0.05 1.2]);

%-----------------Frequency Response--------------------------
figure()
plot(omega1/pi,mag1,'r',omega2/pi,mag2,'k',omega3/pi,mag3,'m',omega4/pi,mag4,'c','LineWidth',2);
xlabel('Normalized frequency');
ylabel('Gain DB');grid
legend('Rectangular','Hanning','Hamming','kaiser');
title('Frequency Responses of Windows');

%V10_2.m: Design a low-pass FIR filter using Rectangular window

% Design a low-pass FIR filter, with cut-off frequency of 5 kHz, length 11
% using rectangular window. Assume the sampling frequency is 50 kHz.
% Find the filter coefficients, measure the magnitude and phase
% responses and comment. Plot the magnitude and phase versus real frequency f in Hz.
%
% Solution                                                                                                                                   
% Cut-off frequency given is 5kHz = 0.2 radians/sec
% rectangular window

clear all; close all; clc;

N=11;
Rw=boxcar(N);
b=fir1(10,0.2,Rw);
disp('window coefficient = ');disp(Rw')

[h,f]=freqz(b,1,512);% frequency response of the window
mag = 20*log10(abs(h)); %DB magnitude
an = angle(h);

%------------------------------------------------------------------------
n = 0:N-1;
figure(); stem(n, Rw,'m','fill','LineWidth',1.5); grid
xlabel('Time index ------>');
ylabel('Magnitude--->');
title('Rectangular Window');
axis([-1 N -0.05 1.05]);

%------------------------------------------------------------------------
% Magnitude Response
figure();
subplot(2,1,1);plot(f,mag,'r','LineWidth',1.5); grid
xlabel('Real frequency ----->');ylabel('Gain DB ----->');
title('Magnitude Response');

% Phase response
phase = angle(h);
subplot(2,1,2); plot(f,phase,'b','LineWidth',1.5);
xlabel('Real frequency ---->');ylabel('Angle in Radians ---->');
title('Phase response'); grid
%------------------------------------------------------------------------


% Result                                                                                                                                      
%
% Filter coefficient
%
% b =
% % 0.00000000000000   0.03989988227886   0.08607915423243   0.12911873134864
% 0.15959952911546   0.17060540604922   0.15959952911546   0.12911873134864
% 0.08607915423243   0.03989988227886   0.00000000000000

% Window coefficient
% 1     1     1     1     1     1     1     1     1     1     1

% Comments:
% % Cut-off frequency given is 5kHz = 0.2 radians/sec (shown in freq. response
% figure)...................ok
% % Ripples are observed at less than -20dB..............................ok
% % In Phase response we observe linear responses......................ok
% % Which show that overall response is satisfactory.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote