Sei sulla pagina 1di 48

Jaypee Institute of Information Technology, Noida

LAB MANUAL
Digital Signal Processing Lab (10B17EC572)

Department of Electronics and Communication


Engineering

Jaypee Institute of Information Technology, Noida

Department of ECE
Digital Signal Processing Lab (10B17EC572): Lab Experiments

1.

Generation of Discrete Time signals & performs their convolution.

2.

To develop a program for computing Z- transform in factored form, also plot its poles
and zeros, and then determine its ROCs.

3.

To develop a program for computing Inverse Z-transform of a rational transfer


function.

4.

Computation of DFT (Discrete Fourier transform) & IDFT using standard formula.

5.

Computation of DFT using FFT algorithms.

6.

Computation of circular convolution.

7.

To design digital IIR filters using Impulse Invariant method.

8.

To design digital IIR filters using bilinear transformation method.

9.

To develop Program for realization (Direct, Cascade and Parallel) of IIR Digital filters.

10.

Design of digital FIR filters (LPF, HPF, BPF, BRF) using Fourier series method.

11.

Design of digital FIR filters (LPF, HPF, BPF, BRF) using frequency sampling method.

12.

Design digital FIR filters using windows technique.

PREFACE

Digital Signal Processing (DSP) is the mathematical manipulation of an information signal to


modify or improve it in some way. It is characterized by the representation of discrete time, discrete
frequency, or other discrete domain signals by a sequence of numbers or symbols and the processing
of these signals. MATLAB is an essential tool in the practice of engineering, of great significance in
the learning process. It not only helps to illustrate the theoretical results but makes students aware of
the computational issues that engineers face in implementing them.

This laboratory manual contains laboratory exercises based on MATLAB. The purpose of
these exercises is to help reconcile what is and how to points of view on signals and systems.

MATLAB distributed by The Math Works, Inc., are chosen as the platform for these
exercises because they are widely used by practitioners in the field, and because they are capable of
realizing interesting systems. MATLAB approaches to modeling of signals and systems. MATLAB
is a programming language. In MATLAB, one specifies the sequence of steps that construct a signal
or operate on a signal to produce a new signal.

GUIDELINES AND PRECAUTIONS

Be punctual in coming to the lab and be sincere in doing your lab work.

Before starting the lab experiment you must go through the lab manual of that
experiment. Get your doubts clear and then start.

No food, beverages, chewing tobacco and gums is allowed in the lab.

At the end of each lab period, shut down the computer.

Keep the work area neat and clean; arrange the chairs before leaving the laboratory.

Don't misuse the IT facility available in the laboratory.

Dont bring your laptop in the lab without permission of the lab OC.

ECE JIIT NOIDA

EVEN SEMESTER

Experiment - 1
Objective: Introduction to MATLAB and its various applications.
What is MATLAB?
MATLAB is a high-performance language for technical computing. It integrates
computation, visualization, and programming in an easy-to-use environment where
problems and solutions are expressed in familiar mathematical notation.
Typical uses include Math and computation Algorithm development, Data
acquisition Modeling, simulation, and prototyping Data analysis, exploration, and
visualization Scientific and engineering graphics Application development, including
graphical user interface building.
MATLAB is an interactive system whose basic data element is an array that does
not require dimensioning. This allows you to solve many technical computing problems,
especially those with matrix and vector formulations.
The name MATLAB stands for Matrix Laboratory.
MATLAB
(Programming Language)

User-Written Functions

Built -in Functions

Graphics
2-D Graphics
3-D Graphics
Color and Lighting
Animation
Audio & Video

Computations
Linear Algebra
Data Analysis
Signal Processing
Polynomials &
Interpolation
Integration
Solutions of ODEs

Toolboxes
Signal Processing
Image Processing
Statistics
Communications
Symbolic Mathematics etc.

External Interfaces
Interface With C, Java,
and Fortran Programmes

ECE JIIT NOIDA

EVEN SEMESTER

Theory:
A. MATLAB Basics
1. MATLAB Windows

MATLAB Desktop Double Click on the MATLAB program icon to launch


MATLAB. This is where MATLAB puts you when you launch it. It consists of
the following subwindows.
a. Command Window This is main window. It is characterized by the
MATLAB command prompt (>>).Use the Command Window to enter
variables and to run functions and M-file scripts. All commands,
including those for running user-written programs, are typed in this
window at the MATLAB command prompt. To execute a command, you
must press enter or return at end.
b. Current Directory All the files from the current directory are listed
here. You have several options of what you can do with file once you
select it using mouse. You can run, M-files, rename them, delete them,
etc., using right click of mouse.
c. Workspace The MATLAB workspace consists of the set of variables
(named arrays) built up during a MATLAB session and stored in memory.
You add variables to the workspace by using functions, running M-files,
and loading saved workspaces.
d. Command History - Statements you enter in the Command Window are
logged in the Command History. From the Command History, you can
view previously run statements, as well as copy and execute selected
statements. You can also create an M-file from selected statements.

Figure Window - MATLAB directs graphics output to a window that is separate


from the Command Window. In MATLAB this window is referred to as a figure.
The characteristics of this window are controlled by your computer's windowing
system and MATLAB figure properties. Graphics functions automatically create
new figure windows if none currently exist. If a figure already exists, MATLAB
uses that window. If multiple figures exist, one is designated as the current figure
and is used by MATLAB (this is generally the last figure used or the last figure you
clicked the mouse in).
2

ECE JIIT NOIDA

EVEN SEMESTER

Editor Window - Use the Editor/Debugger to create and debug M-files, which are
programs you write to run MATLAB functions. The Editor/Debugger provides a
graphical user interface for text editing, as well as for M-file debugging. To create
or edit an M-file use File -> New or File -> Open, or use the edit function.

Workspace

Command
Window

Editor
Window

Figure
Window

Command
History

MATLAB
Desktop
Figure 1. The MATLAB environment consists of MATLAB Desktop, a figure
window, and an editor window. The figure window and the editor window appear
only when invoked with appropriate commands.
2. Input-Output

Data Type - There are many different types of data that you can work with in
MATLAB. You can build matrices and arrays of floating-point and integer data,
characters and strings, logical true and false states, etc. You can also develop your
own data types using MATLAB classes. Two of the MATLAB data types,
structures and cell arrays, provide a way to store dissimilar types of data in the
same array.
3

ECE JIIT NOIDA

EVEN SEMESTER

There are 15 fundamental data types in MATLAB. Each of these data types is in
the form of a matrix or array. This matrix or array is a minimum of 0-by-0 in size
and can grow to an n-dimensional array of any size.

Dimensioning automatic in MATLAB.

Case sensitivity Case Sensitive, MATLAB requires an exact match for variable
names. For example, if you have a variable a, you cannot refer to that variable as A.
With respect to functions, filenames, objects, and classes on the search path or in
the current directory, MATLAB prefers an exact match with regard to case.
MATLAB runs a function if you do not enter the function name using the exact
case, but displays a warning the first time you do this.

Output Display The output of every command is displayed on the command


window unless MATLAB is directed otherwise. A semicolon at the end of a
command suppresses output.
Output Format - The number of digits displayed is not related to the accuracy. The
display format is set by typing format type on the command line, type format
short e for scientific notation with 5 decimal places, format long e for scientific
notation with 15 significant decimal places and format bank for placing two
significant digits to the right of the decimal, default is format short.

Command History - The Command History window presents a log of the


statements most recently run in the Command Window. Use the arrow, tab, and
control keys on your keyboard to recall, edit, and reuse functions you typed earlier.
Instead of retyping the entire line, press the up arrow key. The previously typed
line is redisplayed. Use the left arrow key to move the cursor, edit if required, and
4

ECE JIIT NOIDA

EVEN SEMESTER

press Enter or Return to run the line. Repeated use of the up arrow key recalls
earlier lines, from the current and previous sessions. Using the up arrow key, you
can recall any line maintained in the Command History window. Similarly, specify
the first few characters of a line you entered previously and press the up arrow key
to recall the previous line.
3. File Types

M-files - MATLAB provides a full programming language that enables you to


write a series of MATLAB statements into a file and then execute them with a
single command. You write your program in an ordinary ASCII text file, giving the
file a name of filename.m. The term you use for filename becomes the new
command that MATLAB associates with the program. The file extension of .m
makes this a MATLAB M-file. M-files can be scripts that simply execute a series
of MATLAB statements, or they can be functions that also accept input arguments
and produce output.

Mat files - The save command in MATLAB saves the MATLAB arrays currently
in memory to a binary disk file called a MAT-file. The term MAT-file is used
because these files have the extension .mat. The load command performs the
reverse operation. It reads the MATLAB arrays from a MAT-file on disk back into
MATLAB workspace. MAT-files provide a convenient mechanism for moving
your MATLAB data between different platforms and for importing and exporting
your data to other stand-alone MATLAB applications.

Fig files Binary files with a .fig extension that can be opened again in
MATLAB as figures. Such files are created by saving a figure in this format using
save or save as options from File menu of Figure window. This contains all the
information required to recreate the figure. To open use open filename. fig.

P files - You can save a preparsed version of a function or script, called P-code
files, for later MATLAB sessions using the pcode function. If you develop an
application that other people can use but you do not want to give source code, then
you give them the corresponding p- files.

Mex files are MATLAB callable FORTTRAN and C programs, with a .mex
extension to the filenames.
5

ECE JIIT NOIDA

EVEN SEMESTER

4. Conversing with MATLAB and General Commands

who - MATLAB replies with the variables in your workspace.


whos - MATLAB replies with the variables in your workspace with their size.
what - MATLAB replies with the current directory and MATLAB files in the directory
clear clears variables from environment
clear all - clears all variables from environment
clear a b - look at workspace, the variables a and b are gone
clc/home - clears the cluttered command window.
close all closes all figure windows
clf clears figure window
pwd shows current working directory
cd - changes current working directory
dir/ls lists content of current working directory
Path gets or sets MATLAB search path
Edit path edits MATLAB search path
copyfile copies a file
mkdir creates a directory
help Lists topic on which help is available. (The most important function for learning
MATLAB on your own).
help function name Lists help on function usage, related functions, and links to help
document. To get info on how to use function)
doc topic - To get a nicer version of help with examples and easy-to-read descriptions
doc + search tab - To search for a function by specifying keywords
lookfor string lists help topic containing string
demo runs the demo program
load - To load variable bindings into the environment
save - To save variables to a file
Control+C local abort, terminate current command execution
Quit/Exit exits MATLAB

ECE JIIT NOIDA

EVEN SEMESTER

B. Scripts
Scripts are collection of command executed in sequence, written in editor and
saved as M-files (.m extension). A script file is executed by typing its name in at
command prompt. All of the MATLAB examples in this textbook are contained in M-files
that are available at the MathWorks ftp site.
MATLAB requires that the M-file must be stored either in the working directory or in a
directory that is specified in the MATLAB path list. For example, consider using
MATLAB on a PC with a user-defined M-file stored in a directory called
"\MATLAB\MFILES". Then to access that M-file, either change the working directory by
typing cd\matlab\mfiles from within the MATLAB command window or by adding the
directory to the path. Permanent addition to the path is accomplished by editing the
\MATLAB\matlabrc.m file, while temporary modification to the path is accomplished by
typing path(path,'\matlab\mfiles') from within MATLAB.

C. Making and Manipulating Variables


MATLAB is a weakly typed language and there is No need to initialize variables.
MATLAB supports various types, the most often used are
3.84

64-bit double (default)

16-bit char

Other types are also supported: complex, symbolic, 16-bit and 8 bit integers, etc.

First character of variable names must be a LETTER after that, any combination of
letters, numbers and _.

Variable names are CASE SENSITIVE (a is different from A)

Some examples of Built-in variables

i and j can be used to indicate complex numbers

pi has the value 3.1415926

ans stores the last unassigned value (like on a calculator)

Inf and -Inf are positive and negative infinity

NaN represents Not a Number

A variable can be given a value explicitly


7

ECE JIIT NOIDA

EVEN SEMESTER

a = 10

shows up in workspace

Or as a function of explicit values and existing variables


c = 1.3*45-2*a
To suppress output, end the line with a semicolon
cool = 13/3;
Like other programming languages, arrays are an important part of MATLAB
Two types of arrays
o matrix of numbers (either double or complex)
o cell array of objects (more advanced data structure)
Row vector: comma or space separated values between brackets
row = [1 2 5.4 -6.6] or row = [1, 2, 5.4, -6.6];
Command Window:

>> row = [1 2 5.4 -6.6]

row =
1.0000 2.0000 5.4000 -6.6000
Workspace:

Column vector: semicolon separated values between brackets


column = [4; 2; 7; 4]
Command window:

>> column = [4; 2; 7; 4]

column =
4
2
7
4
Workspace:

ECE JIIT NOIDA

EVEN SEMESTER

You can tell the difference between a row and a column vector by:
o Looking in the workspace
o Displaying the variable in the command window
o Using the size function
>> size(row)

>> size(column)

ans =

ans =

To get a vector's length, use the length function


>>length (row)

>> length(column)

ans =

ans =

Make matrices like vectors

Element by element

By concatenating vectors or matrices (dimension matters)

>> a= [1 2; 3 4]

a=

a = [1 2];
b = [3 4];
c = [5; 6];
d = [a; b];
e = [d c];
f = [[e e] ; [a b a]];
str = ['Hello, I am ' 'John'];

Strings are character vectors

ECE JIIT NOIDA

EVEN SEMESTER

Basic Scalar Operations

Arithmetic operations ( + ,- , *, /)
7/45
(1+i) * (2+i)
1/0
0/0

Exponentiation (^)
4^2
(3+4*j) ^ 2

Complicated expressions, use parentheses


((2 + 3) * 3) ^ 0.1

Multiplication is NOT implicit given parentheses


3 (1 + 0.7)

gives an error

The transpose operators turn a column vector into a row vector and vice versa
a = [1 2 3 4+i]
transpose(a)
a'
a.'

The ' gives the Hermitian-transpose, i.e. transposes and conjugates all complex numbers
For vectors of real numbers .' and ' give same result.
If your expression does not fit on one line, use an ellipsis (three or more periods at the end
of the line) and continue on the next line.
c = 1+2+3+...
5+6+7;
Built-in Functions
MATLAB has an enormous library of built-in functions
Call using parentheses passing parameter to function
10

ECE JIIT NOIDA

EVEN SEMESTER

sqrt(2)
log(2), log10(0.23)
cos(1.2), atan(-.8)
exp(2+4*i)
round(1.4), floor(3.3), ceil(4.23)
angle(i); abs(1+i);
Note: Explore these functions using help or doc
MATLAB is based on matrix and vector algebra; even scalars are treated as 1x1 matrices.
Therefore, vector and matrix operations are as simple as common calculator operations.
Addition and Subtraction
Addition and subtraction are element-wise; sizes must match (unless one is a scalar):
The following would give an error
c = row + column
Use the transpose to make sizes compatible
c = row+ column
c = row + column
Can sum up or multiply elements of vector
s = sum (row);
p = prod (row);
Element-Wise Functions
All the functions that work on scalars also work on vectors
t = [1 2 3];
f = exp(t);

is the same as

f = [exp(1) exp(2) exp(3)];

If in doubt, check a functions help file to see if it handles vectors elementwise


Operators (* / ^) have two modes of operation
o element-wise
o standard

11

ECE JIIT NOIDA

EVEN SEMESTER

Operators: element-wise
To do element-wise operations, use the dot: .(.* , ./ , .^). BOTH dimensions must
match (unless one is scalar)!
a = [1 2 3]; b = [4; 2; 1];
a .* b, a./ b, a. ^ b

all errors

a .*b', a./ b, a .^ (b)

all valid

Operators: standard
Multiplication can be done in a standard way or element-wise
Standard multiplication (*) is either a dot-product or an outer-product
Standard exponentiation (^) can only be done on square matrices or scalars
Left and right division (/ \) is same as multiplying by inverse

Automatic Initialization
Initialize a vector of ones, zeros, or random numbers
o = ones(1,10)

% row vector with 10 elements, all 1

z = zeros(23,1)

% column vector with 23 elements, all 0

r = rand(1,45)

% row vector with 45 elements (uniform [0,1])

n = nan(1,69)

% row vector of NaNs (useful for representing uninitialized variables)

The general function call is:


>> var = zeros(M,N);

where M is Number of rows and N is Number of columns.

Note: Explore these functions using help or doc


To initialize a linear vector of values use linspace
a = linspace (0, 10 ,5)

% starts at 0, ends at 10 (inclusive), 5 values

Can also use colon operator (:)


b = 0:2:10

% starts at 0, increments by 2, and ends at or before 10


% increment can be decimal or negative

c = 1:5

% if increment isnt specified, default is 1

To initialize logarithmically spaced values use logspace, similar to linspace, but see help

12

ECE JIIT NOIDA

EVEN SEMESTER

Vector Indexing
MATLAB indexing starts with 1, not 0
a(n) returns the nth element.
The index argument can be a vector. In this case, each element is looked up individually,
and returned as a vector of the same size as the index vector.
x = [12 13 5 8];
a = x (2:3);

a = [13 5];

b = x (1: end-1);

b = [12 13 5];

Matrix Indexing
Matrices can be indexed in two ways
o using subscripts(row and column)
o using linear indices(as if matrix is a vector)
Picking submatrices
A = rand(5)

% shorthand for 5x5 matrix

A(1:3,1:2)

% specify contiguous submatrix

A([1 5 3], [1 4])

% specify rows and columns

To select rows or columns of a matrix, use the:


>> c = [12 5; -2 13]
c=

12

-2

13

d = c(1, :)

>> e = c(:, 2)

>> c (2, :) = [3 6]

d=

e=

c=

12

12

13

% replaces second row of c


MATLAB contains functions to help you find desired values within a vector or matrix
vec = [5 3 1 9 7]
13

ECE JIIT NOIDA

EVEN SEMESTER

To get the minimum value and its index:


[minVal, minInd] = min(vec);

% max works the same way

To find any the indices of specific values or ranges


ind = find(vec == 9);
ind = find(vec > 2 & vec < 6);

%find expressions can be very complex,

To convert between subscripts and indices, use ind2sub, and sub2ind. Use help.

D. Functions
User-defined Functions
Functions look exactly like scripts, but for ONE difference, Functions must have a
function declaration

Function
Declaration

O/Ps

Inputs
Help
Files

Some comments about the function declaration

14

ECE JIIT NOIDA

EVEN SEMESTER

No need for return: MATLAB 'returns' the variables whose names match those in the
function declaration
Variable scope: Any variables created within the function but not returned disappear after
the function stops running

E. Flow Control
Relational Operators < > <= >= == ~=
MATLAB uses mostly standard relational operators

equal ==

notequal ~=

greater than >

less than <

greater or equal >=

less or equal <=

Logical operators

And

elementwise

short-circuit (scalars)

&

&&

Or

||

Not

Xor

xor

All true

all

Any true

any

Boolean values: zero is false, nonzero is true


See help . for a detailed list of operators
if/else/elseif - Execute statements if additional condition is true
Syntax
if expression1
statements1
elseif expression2
statements2
end

15

ECE JIIT NOIDA

EVEN SEMESTER

Description
If expression1 evaluates as false and expression2 as true, MATLAB executes the one or
more commands denoted here as statements2.
A true expression has either a logical 1 (true) or nonzero value. For nonscalar expressions,
(for example, is matrix A less then matrix B), true means that every element of the
resulting matrix has a true or nonzero value.

For - Execute block of code specified number of times


Syntax
for variable
expression
statements
end
Description
The columns of the expression are stored one at a time in the variable while the following
statements, up to the end, are executed.
In practice, the expression is almost always of the form scalar: scalar, in which case its
columns are simply scalars.
The scope of the for statement is always terminated with a matching end.
while - Repeatedly execute statements while condition is true
Syntax
while expression
statements end
Description
while repeats statements an indefinite number of times. The statements are executed while
the real part of expression has all nonzero elements. expression is usually of the form
expression relational operator expression where relational operator is ==, <, >, <=, >=, or
~=. The scope of a while statement is always terminated with a matching end.

16

ECE JIIT NOIDA

EVEN SEMESTER

F. Plotting
x = linspace(0,4*pi,10);
y = sin(x);
Plot values against their index
plot(y);
Usually we want to plot y versus x
plot( x , y);
Plot generates dots at each (x, y) pair and then connects the dots with a line
To make plot of a function look smoother, evaluate at more points
x = linspace (0, 4*pi, 1000);
plot(x, sin(x));
x and y vectors must be same size or else youll get an error
plot ([1 2], [1 2 3])

error!

Can change the line color, marker style, and line style by adding a string argument
plot (x, y, k.-);
Can plot without connecting the dots by omitting line style argument
plot (x, y, .)
Look at help plot for a full list of colors, markers, and linestyles
Some Other Useful Commands:
xlabel, ylabel, title, xlim, ylim, grid, axis, hold, stem
Cartesian Plots Commands: plot, semilogx, semilogy, loglog
3D Line Plot Command: plot3, surf, contour, quiver, xlim, ylim, zlim
subplot for Multiple Plots in one Figure

G. Solving Equations
Systems of Linear Equations
Given a system of linear equations
x + 2y - 3z = 5,

-3x y + z = -8,

xy+z=0

Construct matrices so the system is described by Ax = b


A = [1 2 -3; -3 -1 1; 1 -1 1];
17

ECE JIIT NOIDA

EVEN SEMESTER

b = [5; -8; 0];


And solve with a single line of code!
x = A\b;

% x is a 3x1 vector containing the values of x, y, and z

The \ will work with square or rectangular systems.


Gives least squares solution for rectangular systems. Solution depends on whether the
system is over or underdetermined.
Given a matrix
m = [1 2 -3; -3 -1 1; 1 -1 1];
Calculate the rank of a matrix
r = rank(m);

% the number of linearly independent rows or columns

Calculate the determinant


d = det(m);

% m must be square, if determinant is nonzero, matrix is invertible

Get the matrix inverse


E = inv(m);

% if an equation is of the form A* x = b with A a square matrix, x = A\b

is the same as x = inv(A) * b


Polynomials
Many functions can be well described by a high-order polynomial
MATLAB represents polynomials by a vector of coefficients
if vector P describes a polynomial ax3 + bx2 + cx + d
P = [1 0 -2] represents the polynomial x2 - 2
P = [2 0 0 0] represents the polynomial 2x3
P is a vector of length N+1 describing an N-th order polynomial
To get the roots of a polynomial
r = roots(P)

% r is a vector of length N

Can also get the polynomial from the roots


P = poly(r)

% r is a vector length N

Numerical Differentiation
MATLAB can 'differentiate' numerically
x = 0:0.01:2*pi;

18

ECE JIIT NOIDA

EVEN SEMESTER

y = sin(x);
dydx = diff(y) ./ diff(x);

% diff computes the first difference

Can also operate on matrices


mat = [1 3 5; 4 8 6];
dm = diff(mat,1,2)

% first difference of mat along the 2nddimension, dm=[2 2;4 -2]

Numerical Integration
MATLAB contains common integration methods
Adaptive Simpson's quadrature (input is a function)
Write a function y = myFun(x) where y = cos (exp(x) +x.^2 - 1)
q1 = quad ('myFun', 0, 10);

% q1 is the integral of the function myFun from 0 to 10

q2 = quad (@(x) sin(x)*x, 0, pi) % q2 is the integral of sin(x)*x from 0 to pi


See function handle
Trapezoidal rule (input is a vector)
x = 0:0.01:pi;
z = trapz(x, sin(x));

%z is the integral of sin(x) from 0 to pi

H. Data Structures
We have used 2D matrices

Can have n-dimensions

Every element must be the same type (ex. integers, doubles, characters)

Matrices are space-efficient and convenient for calculation

Large matrices with many zeros can be made sparse:

a = zeros(100); a(1,3) =10; a(21, 5) = pi; b = sparse(a);


Sometimes, more complex data structures are more appropriate

Cell array: it's like an array, but elements don't have to be the same type

Structs: can bundle variable names and values into one structure like object
oriented programming in MATLAB

19

ECE JIIT NOIDA

EVEN SEMESTER

I. Symbolics
Symbolic Variables
Symbolic variables are a type, like double or char
To make symbolic variables, use sym
a=sym ('1/3');
b=sym ('4/5');
mat=sym ([1 2;3 4]);

% fractions remain as fractions

c=sym ('c', 'positive');

% can add tags to narrow down scope


% see help sym for a list of tags

Or use syms
syms x y real

% shorthand for x=sym ('x', 'real'); y=sym ('y', 'real');

Symbolic Expressions
Multiply, add, divide expressions
d = a*b

% does 1/3*4/5=4/15;

expand ((a-c) ^ 2);

% multiplies out

factor (ans)

% factors the expression

matInv = inv(mat)

% Computes inverse symbolically

Cleaning up Symbolic Statements


pretty (ans)

% makes it look nicer

collect (3*x+4*y-1/3*x^2-x+3/2*y)

% collects terms

simplify (cos(x) ^ 2+sin(x)^2)


subs (c^2, c, 5)

% simplifies expressions
% Replaces variables with numbers or expressions.

To do multiple substitutions pass a cell of variable names followed by a cell of values


subs(c^2, c, x/7)

20

ECE JIIT NOIDA

EVEN SEMESTER

POST LAB EXERCISE


For problems 1- 4, write a script called simpleProblems.m and put all the commands in it.
Separate and label different problems using comments.
1. Scalar variables. Make the following variables

a. a = 10
b. b = 2.5 10 23
c. c = 2 + 3i , where i is the imaginary number
d. d = ej 2 /3 , where j is the imaginary number and e is Eulers number (use exp, pi)
2. Vector variables. Make the following variables

3. Matrix variables. Make the following variables

21

ECE JIIT NOIDA

EVEN SEMESTER

f. Make fMat be a 5x3 matrix of random integers with values on the range -3 to 3 (use
rand and floor or ceil).
4. Common functions and indexing.

22

ECE JIIT NOIDA

EVEN SEMESTER

5. Plotting multiple lines and colors. Open a script and name it twoLinePlot.m
To plot a sine wave and a cosine wave over one period
(a) Make a time vector t from 0 to 2 with enough samples to get smooth lines, Plot sin t.
(b) Use hold on.
(c) Plot cos t using a red dashed line.
(d) Add labels to the plot and create a legend to describe the two lines you have plotted by
using legend.
(e) Use xlim to set the x axis to be from 0 to 2 and use ylim to set the y axis to be from 1.4 to 1.4.

6. Plot a circle. Write the function [x, y] = getCircle (center,r) to get the x and y
coordinates of a circle. The circle should be centered at center (2-element vector containing
the x and y values of the center) and have radius r. Return x and y such that plot(x, y) will
plot the circle.

7. Loops and flow control. Make function called loopTest(N) that loops through the
values 1 through N and for each number n it should display n is divisible by 2, n is
divisible by 3, n is divisible by 2 AND 3 or n is NOT divisible by 2 or 3. Use a for
loop, the function mod or rem to figure out if a number is divisible by 2 or 3, and num2str
to convert each number to a string for displaying. You can use any combination of if, else,
and elseif.

8. Linear system of equations. Solve the following system of equations:


3a + 6b + 4c = 1.

a + 5b = 2.

7b + 7c = 3

9. Numerical integration. Use trapz or quad. What is the value of :

Compute and display the difference between your numerical answer and the analytical
answer: 24 e

5/3

+9

23

ECE JIIT NOIDA

EVEN SEMESTER

10. Practice with cells. Usually, cells are most useful for storing strings, because the
length of each string can be unique. a. Make a 3x3 cell where the first column contains the
names: Joe, Sarah, and Pat, the second column contains their last names: Smith,
Brown, Jackson, and the third column contains their salaries: $30,000, $150,000, and
$120,000. Display the cell using disp.

24

ECE JIIT NOIDA

EVEN SEMESTER

Experiment - 2
Objective: Introduction of Elementary and Complex Signals.
Theory:
The Signals, which are functions of one or more independent variables, contain
information about the behaviour or nature of some phenomenon. Independent variables
may be time, space etc. depending on type of signals. Some examples are: a speech signal
would be mathematically represented by acoustic pressure as a function of time, Voltage,
current or power as functions of time, a monochromatic picture can be described as a
signal which is mathematically represented by brightness as a function of two spatial
variables,
The purpose of this lab is the introduction of the graphical representation of
elementary as well as Complex Signals. For this Lab, our focus will be on a single (1-D)
independent variable which we call time. Depending on time, signals can be classified
into continuous and discrete-time signals used in linear systems. It is important to
emphasize that. A continuous-time signal takes on a value at every point in time, whereas a
discrete-time signal is only defined at integer values of the time variable. However,
while discrete-time signals can be easily stored and processed on a computer, it is
impossible to store the values of a continuous-time signal for all points along a segment of
the real line.
How then do we process continuous-time signals? In this lab, we will see that
continuous- time signals may be processed by first approximating them by discrete-time
signals using a process known as sampling. We will see that proper selection of the
spacing between samples is crucial for an efficient and accurate approximation of a
continuous-time signal. Excessively close spacing will lead to too much data with not
much improvement in signal representation, whereas excessively distant spacing will lead
to a poor approximation of the continuous-time signal.
2. Continuous-Time Vs. Discrete-Time Signals
The representation of continuous-time signals on a computer depends on sampling
process. Selection of the sampling interval decides the precision of graphical
representation of CT signal by discrete values. To display CT and DT signal on
MATLAB see plot, stem, subplot commands.
It is common to graph a discrete-time signal as dots in a Cartesian coordinate
system. This can be done in the Matlab environment by using the stem command. We will
also use the subplot command to put multiple plots on a single figure. Start Matlab on
your workstation and type the following sequence of commands in a script file.
1 % Generate discrete-time sinusoidal signal
2 n = 0: 2: 60;
3 y = sin(n/6);
4 subplot(3,1,1)
5 stem(n, y)
This plot shows the discrete-time signal formed by computing the values of the function
sin (n/6) at points which are uniformly spaced at intervals of size 2. Notice that while sin(t
25

ECE JIIT NOIDA

EVEN SEMESTER

/6)is a continuous-time function, the sampled version of the signal, sin(n/6), is a discretetime function.
A digital computer cannot store all points of a continuous-time signal since this
would require an infinite amount of memory. It is, however, possible to plot a signal which
looks like a continuous-time signal, by computing the value of the signal at closely spaced
points in time, and then connecting the plotted points with lines. The Matlab plot function
may be used to generate such plots.
Steps for plotting continuous time signals are as follows:
1). Assign the value dt very small, as per Sampling Theorem.
2). Vary the timet between two points with an increment of dt.
Use the following sequence of commands in a script file to generate two continuous-time
plots of the signal sin (t/6).
1 % Generate Continuous-time sinusoidal signal
2 t1 = 0:0.1:6,
3 z = sin(t1/6);
4 subplot(3,1,2)
5 plot(t1,z)
6 t2 = 0:2:60;
7 w = sin(t2/6);
8 subplot(3,1,3)
9 plot(t2,w)
As you can see, it is important to have many points to make the signal appear smooth. So,
the selection of sampling period is critical in getting CT signal smooth, it must be chosen
such that smooth plot is obtained at the same with not much large array size with not much
improvement in graphical representation of CT signal.
For given CT signal, Steps for converting CT signal to the DT signal are as
follows:
1) Assign the value of sampling time, T.
2) Vary the time integer n between two integer points with an increment of 1.
3) The discrete version can be obtained as:
y (n) = y(nT).

IN LAB EXERCISE
Basic CT Signals and DT Signals
Q1. Plot the following continuous-time functions over the specified intervals. Write single
script files for all CT signals with name CTsignals_GroupNo. X.m. Use the plot and
figure command, and be sure to label the time axes.
(a) Unit Impulse function, x1 (t) = (t)
(b) Unit Step function, x2(t) = u (t) for t = [-2, 2]
26

ECE JIIT NOIDA

EVEN SEMESTER

(c) Unit Ramp function, x3(t) = r (t) for t = [-2, 5]


(d) sinusoidal function, x4(t) = 3*sin(2*pi*f*t), where f = 200 Hz for t = - 1 to 1 secs
(e) Exponential function, x5(t) = e-at for t = [-4, 4] for a= 0.5, 1.5. Comment on the effect
of time scaling.
(f) rect(t) for t = [ -2 , 2]
(g) sinc(t) for t = [-1, 10]
Hint: These functions may be computed in Matlab by using a Boolean expression. For
example, if t = -10: 0.1: 10, then y = u (t) may be computed using the Matlab command x =
t > 0.
Q2. Also write another .m - script file to stem the corresponding discrete-time function
with name DTsignals_GroupNo. X.m. Use the subplot command to put Q2.a) - c) plots in a
figure 1, Q2.d) - e) plots in a figure 2 and Q2.f) - g) plots in a figure 3. Issue the command
orient (tall) just prior to printing to prevent crowding of the subplots.
Random Signals
The objective of this section is to show how two signals generated using same
script file and look similar can be distinguished by computing their average over a large
interval.
Q3. Generate two discrete-time signals called sig1 and sig2 of length 1, 000. The samples
of sig1 should be independent, Gaussian random variables with mean 0 and variance 1.
The samples of sig2 should be independent, Gaussian random variables with mean 0.2 and
variance 1. Use random or randn to generate these signals, and then plot them in a same
figure. (An alternative name for a Gaussian random variable is a normal random variable.)
Next form a new signal ave1(n) of length 1, 000 such that ave1(n) is the average of the
vector sig1(1:n) (the expression sig1(1:n) returns a vector containing the first n
elements of sig1). Similarly, compute ave2(n) as the average of sig2(1:n). Plot the
signals ave1(n) and ave2(n) versus n on a same plot.
Comment on how the average values changes with n.
POST LAB EXERCISE
Q1.Generate the waveform of following signals:
For CT signals, t = is -10 to 10 sec
Take appropriate value of sampling interval.
(a)
(b)
(c)
(d)
(e)
(f)

xa(t) = (t + 2)
xb(t) = (t + 2) - (t -2)
xc(t) = t u(t)
xd(t) = u (t) u(t - 5)
xe(t) = r (t +1) r (t) + r (t - 2)
xf(t) = exp(-t) sin(2t) + exp(-t/2) cos(5 t)

27

ECE JIIT NOIDA

EVEN SEMESTER

Q2. For DT signals, n = -5 to 5 samples


a.
b.
c.
d.
e.
f.

xa[n] = r[-n]
xb[n] = exp(n-1)
xc[n] = [n - 1] [n - 2]
xd[n] = u [n + 1] 2u[ n] + u [n-1]
xe[n] = r [n + 2] r [n - 2]
xf [n] = a n cos(2 n)

Q3. Sketch the waveform:

b. Using the result of part (a), compute the derivative of v(t), and sketch its waveform.
Q4. Sketch the waveform:

28

ECE JIIT NOIDA

EVEN SEMESTER

Experiment-3
Objective: To compute the linear convolution of two discrete sequences.
Theory: Consider two finite duration sequences x (n) and h (n), the duration of x (n) is n1
samples in the interval 0 n (n1 1) . The duration of h (n) is n2 samples; that is h (n) is
non zero only in the interval 0 n (n 2 1) . The linear or a periodic convolution of x (n)
and h (n) yields the sequence y (n) defined as,

Clearly, y (n) is a finite duration sequence of duration (n1+n2 -1) samples.


The convolution sum of two sequences can be found by using following steps
Step1:Choose an initial value of n, the starting time for evaluating the output
sequence y (n). If x (n) starts at n=n1 and h (n) starts at n= n2 then n = n1+ n2 -1 is a
good choice.
Step2: Express both sequences in terms of the index m.
Step3: Fold h (m) about m=0 to obtain h (-m) and shift by n to the right if n is positive and
left if n is negative to obtain h (n-m).
Step4: Multiply two sequences x (n-m) and h (m) element by element and sum the products
to get y (n).
Step5: Increment the index n, shift the sequence x (n-m) to right by one sample and repeat
step4.
Step6: Repeat step5 until the sum of products is zero for all remaining values of n.

29

ECE JIIT NOIDA

EVEN SEMESTER

Experiment-4
Objective: Computation of DFT (Discrete fourier transform) & IDFT using standard formula
We know that aperiodic finite energy signals have continuous spectra (DTFT).

.In case of a finite length sequence x(n), 0nL-1., Then only L


X ( ) = x(n)e
jn
n

values of X() over its period, called the frequency samples, are sufficient to determine
x(n) and hence X(). This leads to the concept of discrete Fourier transform (DFT) which
is obtained by periodic sampling of X () (DTFT).
We often compute a higher point (N point) DFT where N > L . This is because padding
the sequence x(n) with N-L zeros and computing an N point DFT results in a better
display of the Fourier transform X().
To summarize, the formulas are (for causal sequence)
N 1

X (k)

x(n)e

j 2 kn
N

n 0
N 1

x(n)

1
N

L 1

x(n)e

j 2 kn
N

(DFT ), k

n 0

X (k )e

j 2 kn
N

(IDFT ), n

0,1,......N

k 0

General DFT matrix equation.


X=WN x
X=

WN* X

DFT equation
IDFT equation

Where WN=e-j2/N
x=[x(0) x(1) x(N-1) ]T
X=[X(0) X(1) X(N-1)]T

30

0,1,...., N 1

ECE JIIT NOIDA

EVEN SEMESTER

DSP Lab Exercise:


(DFT)

Ques 1. Find the DFT-transform of the following signals


x(n)={1,2,3,2}
Ques 2.

Find the IDFT of X(K)={4,2,0,4}

Ques 3. Find the DFT-transform of the following signals


x(n)={1,1,0,0,0,0,0,0}
Ques 4.

Find the IDFT of X(K)={1,0,1,0}

31

ECE JIIT NOIDA

EVEN SEMESTER

Experiment-5
Objective: To develop programs for computing Z- transform and Inverse Z-transform.

Part A
The Z-transform of a discrete time signal x(n) is
n

X (z) x(n)z n
n

where, z is a complex variable. Since z-transform is an infinite series, it exists only for those
values of z for which this series converges. The region of convergence (ROC) of X(z) is the
set of all values of z for which X(z) attains a finite value.

Example:
x(n) is a finite duration signal like x(n) 1,2,5,7,0,1 .
Its z transformed signal, X (z) 1 2z 1 5z 2 7z 3 z 5 , its ROC is entire Z-plane
except z=0.
For x(n) 1,2,5,7,0,1 , its z transformed signal is X (z) z 2 2z 5 7z 1 z 3 , here its
ROC is entire Z-plane except z=0 and z= .

Z transform of different functions:


Sequence

Transform

ROC

[n]
u[n]
-u[-n-1]
[n-m]
anu[n]
-a nu[-n-1]
nanu[n]
-na nu[-n-1]
[cos0n]u[n]
[sin0 n]u[n]
[rncos0n]u[n]
[rnsin0 n]u[n]
anu[n] - a nu[n-N]

1
all z
z/(z-1)
|z|>1
z/(z-1)
|z|<1
z-m
all z except 0 if m>0 or
z/(z-a)
|z|>|a|
z/(z-a)
|z|<|a|
2
az/(z-a)
|z|>|a|
az/(z-a)2
|z|<|a|
2
2
(z -[cos0]z)/(z -[2cos0]z+1)
|z|>1
[sin0]z)/(z2-[2cos0]z+1)
|z|>1
2
2
2
(z -[rcos0]z)/(z -[2rcos0]z+r )
|z|>r
[rsin0]z)/(z2 -[2rcos0]z+r2)
|z|>r
N N
N-1
(z -a )/z (z-a)
|z|>0

32

m<0

ECE JIIT NOIDA

EVEN SEMESTER

Part B
Inverse Z-transform
The inverse Z-transform is the conversion of Z-domain signal into time domain signal. The
inversion can be done by Cauchys Integral theorem, long division process, partial fraction
expansion etc.

I) Partial fraction expansion:


Suppose a function X(z) is given in Z-domain.

To convert it in the time domain, it is expressed as

Then performing partial fraction expansion on the proper rational part of X(z) to obtain

Now the time domain signal x(n) is

33

ECE JIIT NOIDA

EVEN SEMESTER

DSP Lab Exercise:


(Z-transform)
Ques 1. Find the Z-transform of the following signals and also find the R.O.C
. x(n)={2,1,3,-4,1,2}
Ques 2.

Find the inverse Z-transform of the signal


-1

X(z)

-2

(1 2z z )

(1- z -1 0.3561z -2 )
Ques 3. Determine whether or not all the roots of the following polynomial are inside the
unit circle:

X(z) (1 2.5z-1 2.5z-2 1.25z -3 0.3125z-4 0.03125z-5 )


Ques 4. Find the Z-transform of the following signals
. x(n)=n+1

Ques 5. Determine whether or not all the roots of the following polynomial are inside the
unit circle:

X(z) (1 0.2z -1 0.3z-2 0.4z-3 0.5z-4 0.6z-5 )


Ques 6.

Find the residues of the following polynomial

3
(z
)
X(z)
(z - 0.5)(z - 0.75)(z -1)

34

ECE JIIT NOIDA

EVEN SEMESTER

Experiment-6
Objective: To compute the circular convolution of two discrete sequences.
Theory: Two real N-periodic sequences x(n) and h(n) and their circular or periodic
convolution sequence y(n) is also an N- periodic and given by,
N 1

y(n) h(m)x((n m)) N , for n=0 to N-1.


m0

Circular convolution is some thing different from ordinary linear convolution operation,
as this involves the index ((n-m))N, which stands for a modula-N operation. Basically
both type of convolution involve same six steps. But the difference between the two types
of convolution is that in circular convolution the folding and shifting (rotating)
operations are performed in a circular fassion by computing the index of one of the
sequences with modulo-N operation. Either one of the two sequences may be folded and
rotated without changing the result of circular convolution. That is,
N 1

y(n) x(m)h((n m)) N , for n=0 to (N-1).


m0

If x (n) contain L no of samples and h (n) has M no of samples and that L > M, then
perform circular convolution between the two using N=max (L,M), by adding (L-M) no of
zero samples to the sequence h (n), so that both sequences are periodic with number.
Two sequences x (n) and h (n), the circular convolution of these two sequences
can be found by using the following steps.
1.

Graph N samples of h (n) as equally spaced points around an outer circle in


counterclockwise direction.

2.

Start at the same point as h (n) graph N samples of x (n) as equally spaced points
around an inner circle in clock wise direction.

3.

Multiply corresponding samples on the two circles and sum the products to produce
output.

4.

Rotate the inner circle one sample at a time in counter clock wise direction and go to
step 3 to obtain the next value of output.

5.

Repeat step No.4 until the inner circle first sample lines up with first sample of the
exterior circle once again.

35

ECE JIIT NOIDA

EVEN SEMESTER

DSP Lab Exercise:


(Circular convolution)
Ques 1. Find circular convolution of the following signals
x(n)={1,2,1,2}, h(n)={4,3,2,1}
Ques 2. Find circular convolution of the following signals
x(n)={1,2,0,1}, h(n)={2,2,1,1}
Ques 3. Find circular convolution of the following signals x(n)={1,1,1,1}, h(n)={1,2,3,4}
Ques 4. Find circular convolution of the following signals
x(n)={1,3,4,5}, h(n)={2,1,4,1}
Ques 5. Find linear convolution of the following signals using circular convolution
x(n)={1,2,4}, h(n)={2,5}
Ques 6. Find linear convolution of the following signals using circular convolution
x(n)={5,3}, h(n)={2,4,6}

36

ECE JIIT NOIDA

EVEN SEMESTER

Experiment-7
Computation of DFT using FFT algorithms

(d) Spectral Estimation of the Sum of Sinusoids

MATLAB

1. Write a program to compute and plot the amplitude spectrum of the signal x(n) with the number of
data points you have determined based on FFT. Comment on your results.

37

ECE JIIT NOIDA

EVEN SEMESTER

Experiment-8
Objective: Write a program to design the low pass FIR filter using the following
Windowing techniques and specifications:
Window techniques
1) Hamming Window
2) Kaiser Window
Specifications
passband edge frequency: 1800 Hz,
stopband edge frequency: 2600 Hz,
maximum passband ripple: 0.5 dB,
minimum stopband damping: 40 dB,
sampling rate: 8 kHz.
sample sinusoids at frequencies:
a. F1=500 Hz
b. F2=1800 Hz
c. F3=2000 Hz
d. F4=3200 Hz
Theory:
The FIR filter design consists of two steps;
1) The filter order is determined, then the coefficients.
2) An approximate formula for the filter order N, developed by Kaiser:

Steps to design MATLAB Code:


1) Create sampled sinusoids at different frequencies.
2) Calculate samples for a 4-tone input signal
3) Design FIR Filter using any window.
4) Plot frequency response - both amp and phase response.
5) Apply this filter to the 4-tone test sequence.

38

ECE JIIT NOIDA

EVEN SEMESTER

Results:
a) Kaiser Window
0

Magnitude (dB)

-20

&

-40
-60
-80
-100
-120

0.1

0.2

0.3

0.4
0.5
0.6
Normalized Frequency (rad/sample)

0.7

0.8

0.9

0.1

0.2

0.3

0.4
0.5
0.6
Normalized Frequency (rad/sample)

0.7

0.8

0.9

Phase (degrees)

500

-500

39

ECE JIIT NOIDA

EVEN SEMESTER

Time Plots of Input and Output


4

Input S ig

2
0

&

-2

VK

-4
0

0.005

0.01

0.015

0.02

0.025

0.015

0.02

0.025

time (s)

F iltered S ig

2
1
0
-1
-2
0

0.005

0.01
time (s)

40

ECE JIIT NOIDA

EVEN SEMESTER

b) Hamming Window

Magnitude (dB)

5
0

&

-5
-10
-15

0.1

0.2

0.3
0.4
0.5
0.6
0.7
0.8
Normalized Frequency (rad/sample)

0.9

0.1

0.2

0.3
0.4
0.5
0.6
0.7
0.8
Normalized Frequency (rad/sample)

0.9

Phase (degrees)

-500

-1000

-1500

41

ECE JIIT NOIDA

EVEN SEMESTER
Time Plots of Input and Output

VK
&

Input Sig

2
0
-2
-4
0

0.005

0.01

0.015

0.02

0.025

0.015

0.02

0.025

time (s)

Filtered Sig

4
2
0
-2
-4
0

0.005

0.01
time (s)

42

ECE JIIT NOIDA

EVEN SEMESTER

Experiment-9 & 10
Objective: Write a program for IIR digital filter design (Impulse invariant and
Bilinear transformation) for a given specification.

Theory:
IIR Filter Types
1) Butterworth filter
Provides the best Taylor series approximation to the ideal lowpass filter response at
analog frequencies = 0 and = ; for any order n, the magnitude squared response has
2n 1 zero derivatives (that is, it is maximally flat) at these locations. Response is
monotonic overall, decreasing smoothly from = 0 to = .
2) Chebyshev Type I filter
It minimizes the absolute difference between the ideal and the actual frequency response
over the entire passband by using an equal ripple in the passband. Stopband response is
maximally flat. The transition from passband to stopband is more rapid than for the
Butterworth filter.
3) Chebyshev Type II filter
It minimizes the absolute difference between the ideal and the actual frequency response
over the entire stopband by using an equal ripple in the stopband. Passband response is
maximally flat. The stopband does not approach zero as quickly as the type I filter. The
absence of ripple in the passband, however, is often an important advantage.
4) Elliptic filter
Equiripple in both the passband and stopband. Generally meets filter requirements
with the lowest order of any supported filter type. Given a filter order n, passband
ripple, and stopband ripple, elliptic filters minimize transition width.
For designing Butterworth filter, the commands are
[num, den] = butter(N, Wn)
For designing a Type 1 Chebyshev digital filter, the commands are
[num, den] = cheby1(N, Rp, Wn)
For designing a Type 2 Chebyshev digital filter, the commands are
[num,den] = cheby2(N,Rs,Wn)
For designing Butterworth filter, the commands are
[num, den] = ellip(N, Rp, Rs, Wn)
Each function delivers a lowpass filter by default. To design a bandpass, Wn must be
defined as a vector of 2 elements. The elements hold the corner frequencies of the
bandpass filter. The filter order N and the scaling factor for the frequency bounds Wn can
be determined as follows:
[N, Wn] = buttord(Wp, Ws, Rp, Rs)
[N, Wn] = cheb1ord(Wp, Ws, Rp, Rs)
[N, Wn] = ellipord(Wp, Ws, Rp, Rs

43

ECE JIIT NOIDA

EVEN SEMESTER

Where, the input parameters are the normalized passband edge frequency Wp, the
normalized stopband edge frequency Ws, the passband ripple Rp in dB, and the minimum
stopband attenuation Rs in dB. Both Wp and Ws must be a number between 0 and 1 with the
sampling frequency assumed to be 2 Hz. The output data are the lowest order N
meeting the specifications and the normalized cutoff frequency Wn. If Rp = 3 dB, then
Wn = Wp. Buttord can also be used to estimate the order of a highpass, a bandpass, and a
bandstop Butterworth filter. For a highpass filter design,Wp > Ws. For bandpass and
bandstop filter designs, Wp and Ws are two-element vectors specifying both edge
frequencies, with the lower edge frequency being the first element of the vector. In the
latter cases, Wn is also a two-element vector.
Digital IIR Filter design
The design of an IIR filter is rather straightforward when using the bilinear transformation
technique. An analog filter is converted to a digital one via the bilinear transformation
we obtain the relation
As the bilinear transformation preserves the type of filter (LP, BP etc.) we only need to
make sure that the cut-off frequencies gets mapped to the correct place.
The design technique is summarized here:
1. Start by identifying the discrete time frequencies describing the cut-off frequencies.
Use normalized frequencies in radians where, = represents half the sampling frequency (
= 2f / fs).
2. Calculate the corresponding analog frequencies using = 2 tan( / 2).
3. Design an analog filter Ha(s) based on the specifications.
4. Use the bilinear transformation to obtain the final digital (Z-domain) filter.

EXERCISE:
1) Using MATLAB determine the lowest order of a digital IIR highpass filter of all four
types. The specifications are as follows: sampling rate of 3,500 Hz, passband edge
frequency of 1,050 Hz, stopband edge frequency of 600 Hz, passband ripple of 1 dB, and a
minimum stopband attenuation of 50 dB. Plot the frequency response of the above IIR
filter for bilinear and impulse invariant transforms. Comment on your results.
2) Using MATLAB determine the lowest order of a digital IIR bandstop filter of all four
types. The specifications are as follows: sampling rate of 12 kHz, passband edge
frequencies at 2.1 kHz and 4.5 kHz, stopband edge frequencies at 2.7 kHz and 3.9 kHz,
passband ripple of 0.6 dB, and a minimum stopband attenuation of 45 dB. Plot the
frequency response of the above IIR filter for bilinear and impulse invariant transforms.
Comment on your results.

44

Potrebbero piacerti anche