Sunteți pe pagina 1din 6

Class Assesement1

1. Plot the following windows of FIR filter on the same plane and analyze it. Choose appropriate
parameters and use mat lab programming.

I. Hamming window

II. Hanning window

III. Rectangular window

IV. Triangular window


Matlab code
x=hamming(61);
n=-30:30;
plot(n,x)
hold on
plot(n,hanning(61))
hold on
plot(n,boxcar(61))
hold on
plot(n,triang(61))
legend('Hamming','Hanning','Rectangular','Traingular')
title('Window Comparison')
xlabel('Range of sample');
ylabel('Magnitudes');

1
Matlab output

2. Design a 40th –order FIR band pass filter with pass band of 0.35<=w<=0.65.

Magnitude frequency response

2
I. What will happen when you decrease filter order to 10?

Magnitude frequency response:

When the filter order decrease to 10, the ringing effect of side lobe is removed by windowing (i.e
hamming window)

II. What are the filter coefficients for filter order 10?
Filters coefficient:

3
3. Design a 5-tap FIR band reject filter with a lower cut of frequency of 2,000Hz and an upper
cut of frequency of 2,400Hz and sampling rate of 8,000Hz using hamming window method.

I. Determine the transfer function

Filter coefficient
bo,b1,b2,b3,b4 respectively as follows:

Transfer function:
H ( z ) =0.008+0.009 z−1+ 0.965 z−2 +0.009 z−3 +0.008 z−4
I. Plot magnitude frequency response

4. Calculate the filter coefficients for a 3 tap fir low pass filter with a cut of frequency of 800Hz and
sampling rate of 8,000Hz using hamming window
I. Determine the transfer function and difference equation of the designed fir system
Filter coefficients: b0,b1,b2 are as follows respectively:

Transfer function and difference equation

H ( z ) =0.65+0.869 z−1+ 0.65 z−2

y ( n )=0.65 x ( n ) +0.869 x ( n−1 )+ 0.65 x( n−2)

4
II. Plot magnitude frequency response

Adding and removing noise from signal


Matlab code

Fs = 500; %**sampling frequence of the signal


f=10; %** frequence of the signal
n = [1/Fs:1/Fs:1]; %range of the time axis
x=sin(2*pi*f*n); % the original signal
subplot(5,1,1);
plot(n,x);
%adding noise signal
y=rand(1,length(x)); % random noise signal
z=x+y; % adding the original signal with noisy one
subplot(5,1,2);
plot(n,z);
title('noisy signal');
xlabel('time');
ylabel('amplitude');
%spectral analaysis of the signal
L=length(z);
NEFT=2^nextpow2(L); %number of point
z_fft=abs(fft(z,NEFT)); %fast fourier transforming
%Creating frequency axis
freq=Fs/2*linspace(0,1,NEFT/2+1); %finging frequency responce
%PLOT SINGLE SIDEDAMPLITUDE
subplot(5,1,3);
plot(freq,z_fft(1:length(freq)));
title('single-sided amplitude spectrum of z(t)');
xlabel('frequency (Hz)');
% designing the filter
O = 1; % order of the signal
wn = [8 12]*2/Fs; % digital bandpass normalized frequency
[b,a] = butter(O,wn,'bandpass'); %
%frequency response of filter
%figure;
%freqz(b,a,1024,Fs);
[h,w] = freqz(b,a,1024,Fs);

5
subplot(5,1,4);
plot(w,20*log10(abs(h)));
title('magnitude response of filter');
xlabel('frequency response');
ylabel('magnitude response');
grid on;
%filter the signal
z_filt =filter(b,a,z);
subplot(5,1,5);
plot(n,z_filt);
title('filtered signal');
xlabel('time');
ylabel('amplitude');

output