6
NNAMDI AZIKIWE UNIVERSITY, AWKA FACULTY OF ENGINERRING DEPARTEMENT OF ELECTRONIC AND COMPUTER ENGINEERING DIGITAL SIGNAL PROCESSING ECE 537 OSISIOGU UKACHI O. 2010364149 LECTURER IN CHARGE: Engr. A.C.O. Azubogu, Ph.D FEBRUARY, 2015

Discrete Time Systems

Embed Size (px)

DESCRIPTION

An Assignment on digital Filters using MATLAB

Citation preview

Page 1: Discrete Time Systems

NNAMDI AZIKIWE UNIVERSITY, AWKA

FACULTY OF ENGINERRING

DEPARTEMENT OF ELECTRONIC AND

COMPUTER ENGINEERING

DIGITAL SIGNAL PROCESSING

ECE 537

OSISIOGU UKACHI O.

2010364149

LECTURER IN CHARGE:

Engr. A.C.O. Azubogu, Ph.D

FEBRUARY, 2015

Page 2: Discrete Time Systems

Laboratory exercise 2 Discrete Time Systems: Linear Time-invariant systems

Lab Objective: To design digital filters using MATLAB

Project 2.1

Q 1. Design a moving average filter of order M.

푦[푛] = 1푀 푥[푛 − 푘]

The signal we are to filter is 푥[푛] = 퐴푠푖푛휔푛 + 푉[푛];푉[푛] 푖푠 푎 푤ℎ푖푡푒 푛표푖푠푒 푤푖푡ℎ 푧푒푟표 푚푒푎푛 푎푛푑 푢푛푖푡 푣푎푟푖푎푛푐푒

푊ℎ푒푟푒,휔 = 2휋푓푓 ;푓 = 500퐻푧; 푓 = 8000퐻푧;퐴 = 1200

The copy of program P1 is given below.

%The program P1

% Moving average Filter design

clf

% For White noise with zero mean and unit variance

%The white noise was multiplied by 100 to appreciate the effect

on the

%sinusoidal signal

V_n =100*(randn (1,50));

%Filter Parameter(s)

M = 50;

%Signal Parameters

A = 1200;

f = (500/8000);

w = 2*pi*f;

n = 1:50;

%sinusoidal Signal with noise signal

x_n = (A*sin(w.*n)+ V_n);

b = (1/M)* ones(M,1);

a = 1;

Page 3: Discrete Time Systems

subplot (2,1,1)

y = filter (b,a,x_n);

stem (n,x_n,'b')

grid on

xlabel ('Time index')

ylabel (' Amplitude')

title ('Sinusoidal Input, x[n]')

%The filtered signal shows a fine sinusoidal signal eliminating

the noise.

subplot (2,1,2)

stem (n,y,'r');

grid on

xlabel ('Time index')

ylabel ('Amplitude')

title ('Filtered signal, y[n]'

The sinusoidal signal x[n] with noise V[n] and the filtered signal, y[n] generated by running program P1 is shown below.

Page 4: Discrete Time Systems

Project 2.2: To determine and plot the impulse and step response of an autoregressive moving

average (ARMA) model

Q 2 Given a system described by the following difference equation

푦[푛] − 푦[푛 − 1] + 0.9푦[푛 − 2] = 푥[푛],∀ 푛

Q 2.1 Determine and plot the impulse response h[n] at n = -20 … 100

Answer

The copy of the program P2 is given below

%Program P2

%The impulse response of the Infinite Impulse Response Filter

%y[n]-y[n-1]-0.9y[n-2] = x[n]

clf

b = [1];

a = [1, -1, 0.9];

n = -20:100;

x = [zeros (1, 20) 1 zeros (1,100)];

y = filter (b,a,x);

stem (n,y);

grid on

axis ([-20 100 -1 1]);

xlabel ('Samples (n)');

ylabel ('Output, y[n]');

title ('Impulse Response')

Answer: The impulse response generated by running the program P2 is shown below

In

Page 5: Discrete Time Systems

determining the values of the impulse response at different time intervals MATLAB assumed the

initial condition like y[-1] to be zero. So the output values were computed as thus.

푦[푛] − 푦[푛 − 1]– 0.9[n− 2] = x[n]

For the first 6 non-negative samples from n = 0 to n =5 as shown below

푤ℎ푒푛 푛 = 0; 푦[0] = 푥[0] + 푦[−1] − 0.9푦[−2] = 1 + 0− 0 = 1

;푤ℎ푒푛 푛 = 1; 푦[1] = 푥[1] + 푦[0] − 0.9푦[−1] = 0 + 1 − 0 = 1

푤ℎ푒푛 푛 = 2; 푦[2] = 푥[2] + 푦[1] − 0.9푦[0] = 0 + 1 − 0.9 = 0.1

푤ℎ푒푛 푛 = 3; 푦[3] = 푥[3] + 푦[2] − 0.9푦[1] = 0 + 0.1− 0.9 = −0.8

푤ℎ푒푛 푛 = 4; 푦[4] = 푥[4] + 푦[3] + 0.9푦[2] = 0− 0.8− 0.9(0.1) = −0.9

푤ℎ푒푛 푛 = 5; 푦[5] = 푥[5] + 푦[4] + 0.9푦[3] = 0− 0.89 + 0.72 = −0.17

Q 2.2 Determine and plot the step response, u[n] at n = -20…100

Answer

Copy of program P3 is shown below

%Program P3

%Unit step response of the Infinite Impulse Filter

%y[n]-y[n-1]-0.9y[n-2] = x[n]

clf

b = 1;

a = [1, -1, 0.9];

n = -20:100;

x = [zeros(1,20) ones(1,101)];

y = filter (b,a,x);

stem (n,y)

grid on

xlabel ('Samples (n)')

ylabel ('Output, y[n]')

title ('Unit Step Response')

Page 6: Discrete Time Systems

Answer: The unit step response generated by running program P3 is shown below.

Similarly, for the unit step response 6 non-negative samples were considered

푤ℎ푒푛 푛 = 0; 푦[0] = 푥[0] + 푦[−1] − 0.9푦[−2] = 1 + 0− 0 = 1

;푤ℎ푒푛 푛 = 1; 푦[1] = 푥[1] + 푦[0] − 0.9푦[−1] = 1 + 1 − 0 = 2

푤ℎ푒푛 푛 = 2; 푦[2] = 푥[2] + 푦[1] − 0.9푦[0] = 1 + 2 − 0.9 = 2.1

푤ℎ푒푛 푛 = 3; 푦[3] = 푥[3] + 푦[2] − 0.9푦[1] = 1 + 2.1− 0.9 = 2.2

푤ℎ푒푛 푛 = 4;푦[4] = 푥[4] + 푦[3] + 0.9푦[2] = 1 + 2.2 − 0.9(2.1) = 1.31

푤ℎ푒푛 푛 = 5; 푦[5] = 푥[5] + 푦[4] + 0.9푦[3] = 1 + 1.31 − 0.9(2.2) = 0.33

In conclusion, MATLAB was used to demonstrate the design and functionality of digital filters.