Lab Man DSP
Lab Man DSP
Lab Man DSP
Contents
List of figure:- ........................................................................................................................................ 2
List of Table:- ........................................................................................................................................ 4
Tutorial 1: Introduction to MATLAB ........................................................................................................ 5
Tutorial 2: Introduction to MATLAB ................................................................................................ 13
Experiment Part one: Generation of Discrete-Time Signals in Time Domain ........................................ 26
Lab #1: Generation of Discrete-Time Signals in Time Domain ........................................................... 26
Experiment Part Two: Simulation of Discrete-Time Systems............................................................ 36
Lab#1The Moving Average System ................................................................................................ 36
Lab #2 Discrete-Time Systems in the Time Domain for LTI ................................................................ 39
Lab #3 Linear Convolution ............................................................................................................. 44
Lab #3:- Circular Convolution ........................................................................................................ 46
Experiment Part Three: The Frequency Domain Analysis ................................................................ 49
Lab #1: Discrete-Time Fourier Transform (DTFT) Computation ......................................................... 49
Lab #2:-The Discrete Fourier Transform (DFT) and Inverse DFT Computations ................................. 53
Lab #4:- Z-Transform Analysis ...................................................................................................... 57
Experiment Part Four: Sampling Process .......................................................................................... 61
Lab #1Sampling of Continuous-Time Signal into Discrete-Time Signal .............................................. 63
Lab #2 Aliasing Effect in Time Domain .......................................................................................... 65
Lab #3 Effect of Sampling in Frequency Domain: Aliasing Effect in Frequency .......................... 67
Lab #4 DECIMATION & INTERPOLATION .............................................................................. 70
Experiment Part Five: Digital Filter Design ............................................................................................ 76
Lab #1 Infinite Impulse Response (IIR) Filter Design Based on the Impulse Invariance Method
and Bilinear Transformation .......................................................................................................... 76
Lab #2 Filter Design by Matlab tools ................................................................................................. 84
List of figure:-
Figure T1. 1 Window of the MATLAB 6
Figure T1. 2 graphical help window of the matlab 7
Figure T2. 1 Graphical presentation using plot(x,y) function of the MATLAB 19
Figure T2. 7 Edit Window with a program to demonstrate the animated plot 23
Figure P1L1. 3 The unit step response: sample output of program 1.3 30
Figure P2L1. 1 The illustration of the moving average filter Program 2.1 . 38
Figure P2L1. 5 linearly convolved output of LTI system to a finite length input. 45
List of Table:-
Table P5: 1 Analogue Transformation Functions ................................................................................... 78
Table P5: 2 Transformation from Analogue to Digital Filters ................................................................. 79
Table P5: 3 Direct Design Matlab Functions for IIR Filters .................................................................... 79
However, the Command Window has several other windows, which is shown in Figure T1. 1.
Both Edit Window and Graphical Window modify the existing ones. Similarly, a
Figure/Graphical Window is used to display MATLAB graphics.
The Command Window is the main window of MATLAB. A user can enter MATLAB
commands at the command prompt (>>) in the Command Window and they will be executed. An
Edit/Debug Window is used to create a new MATLAB files (m-files) or to
Editor
Current
Folder
Command
Window
Work
spaceFigure T1. 1 Window of the MATLAB.
To go through MATLAB, one doesn’t need a book. The help facilities available inside the
MATLAB itself is more than sufficient. MATLAB has two ways of getting help; one graphical
help and the next is text help. The graphical help is available from the Command Window itself.
However, the text help is obtained from the command prompt (>>). The Graphical Help Window
is shown in Figure T1. 3.
>>help punct
>>help zeros
>>help ones
T2.1.1 Arrays
The basic data type in MATLAB is the rectangular array, which contains numbers (or even
strings of symbols). MATLAB allows the user to create quite advanced data structures, but for
many scientific applications it is sufficient to work with matrices.
These are two-dimensional arrays of data in the form
𝑎1,1 𝑎1,2 ⋯ 𝑎1,𝑚
A= 𝑎2,1 𝑎2,2 ⋯ 𝑎2,𝑚
𝑎𝑛,1 𝑎𝑛,2 ⋯ 𝑎𝑛,𝑚
Note that the notation implies that ai,j is the element of A which is stored in the ith row and jth
column. The number of rows n need not be the same as the number of columns m. We say that
such a matrix A is of dimension nxm. When n = 1 we have a column vector and when m = 1 we
have a row vector. When n = m = 1, A has a single entry, and is commonly known as a scalar.
You do not need any prior knowledge of matrices to follow the following part of notes. A
matrix can be created in MATLAB using any name starting with a letter and containing only
letters, numbers and underscores (_). A major distinction between MATLAB and many other
programming languages is that in MATLAB one does not have to declare in advance the size of
an array. Storage of arrays is dynamic in the sense that an array with a given name can change
size during a MATLAB session.
The MATLAB command
>>x = exp(1); creates a single number whose value is e and stores it in the variable whose name
is x. This is in fact a 1x1 array.
The command
>>y = [0,1,2,3,4,5];
creates a 1x6 array whose entries are equally spaced numbers between 0 and 5 and stores it in the
variable y. A quicker way of typing this is y = [0:5]. More generally, the command [a:b:c] gives
a row vector of numbers from a to c with spacing b. If the spacing b is required to be 1, then it
can be left out of the specification of the vector. Matrices can change dimension, for example if x
and y are created as above, then the command
>>y = [y,x]
Produces the response
y=
Columns 1 through 7
0 1.0000 2.0000 3.0000 4.0000 5.0000 2.7183
In the example above, we created a row vector by separating the numbers with commas. To
get a column vector of numbers you separate them by semi-colons, e.g. the command
>> z = [1;2;3;4;5]
z=
1
2
3
4
5
creates a 5x1 array of equally spaced numbers between 1 and 5.
>> size(z)
ans =
5 1
Matrices of higher dimension are created by analogous arguments. For example, the command
>> A = [[1,2,3];[4,5,6];[7,8,10]]
1 2 3
puts the matrix into the variable A. Similarly, [4 5 6]
7 8 9
>>C = [16 3 2 13; 5 10 11 8; 9 6 7 12; 4 15 14 1]
C=
16 3 2 13
5 10 11 8
9 6 7 12
4 15 14 1
The transpose of C can be obtained as
>> C'
ans =
16 5 9 4
3 10 6 15
2 11 7 14
13 8 12 1
The sum of the elements on the main diagonal is obtained with the sum and the diag functions.
sum(diag(C))
ans =
34
T2.1.2 Simple Operations
If A and B are two matrices (which must be of the same size)
>> A = [[1,2,3];[4,5,6];[7,8,10]];
>> B = [[11,12,13];[14,15,16];[17,18,19]];
then
>> A+B
ans =
12 14 16
18 20 22
24 26 29
A.*B produces a new matrix, the entries of which are the products of the corresponding entries
of A and B. That is,
A.*B
ans =
11 24 39
56 75 96
119 144 190
Note that the . before the * indicates that the multiplication is done pointwise (or elementwise).
Similarly the pointwise quotient is A./B. Hence it is called scalar operation.
Some of you may also know about the matrix product AB which is defined even when A and B
are not of the same size, as long as the number of columns of A is the same as the number of
rows of B. This (quite different) product is obtained in MATLAB with the command A*B. That
is,
>> A*B
ans =
90 96 102
216 231 246
359 384 409
Every function can be applied to a whole matrix (or more generally array) of numbers. The result
will be an array of the same size, each element of which is the result of the function applied to
the corresponding element of the array or matrix. For example, if
>>y=[0:5];
Then the command
>>z = log(y)
z=
Columns 1 through 6
-Inf 0 0.6931 1.0986 1.3863 1.6094
Note that log is the built-in function which computes loge (or ln) and that the resulting vector y
above is the result of applying loge to each entry of the previous vector y. MATLAB handles an
infinite answer by recording it as Inf and producing a warning. Note that these calculations verify
that loge(1) = 0 and loge(e) = 1.
T2.1.3 MATLAB Build-in Functions with Array
Vectors and matrices can be created in your MATLAB workspace by various methods. For
example there are many built-in commands: zeros(n,m) and ones(n,m) produces nxm matrices of
zeros and ones.
For example:-
>> zeros(3,4)
ans =
0 0 0 0
0 0 0 0
0 0 0 0
The command rand(n,m) produces a random nxm matrix. The command eye(n,n) produces the
nxn identity matrix with ones on its diagonal (from top left to bottom right) and zeros elsewhere.
Try these out for some values of n and m.
For example;-
>> rand(3,2)
ans =
0.8147 0.9134
0.9058 0.6324
0.1270 0.0975
>> rand(3,2)
ans =
0.2785 0.9649
0.5469 0.1576
0.9575 0.9706
>> eye(4,4)
ans =
1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 1
N.B:-Type help command for each of these commands and read the MATLAB manual page for
each of them.
If the entries of a vector or matrix are given by a formula then there is a simple way to create
them, called for loop. For example, if we wish to create a vector x whose entries are the squares
of the natural numbers from 1 to 10 we can use the command
for :-Repeat statements a specific number of times.
The general form of a for statement is:
for variable = expr, statement, ..., statement END
>> for i=1:10; x(i) = i^2; end;x
x=
Columns 1 through 10
1 4 9 16 25 36 49 64 81 100
T2.1.4 Graphics
The simplest plotting command is plot. If x and y are any two vectors of the same size, then the
command
>>x=[0:10];
>>y=[0:0.1:1];
>>plot(x,y)
>>plot(x,y,'r*')
>>stem(x,y)
The resultant plots of all three are shown in Figure T2.1, T2. 2, and T2. 3 which are the
components of y in turn against the components of x, using different mediums.
There are several variations of this command. Type help plot or doc plot --> Graphics -->
Line plotting to find out more about this command. Other simple plotting commands, for which
you should consult the help pages --> Graphics --> 2-D Plots, include fplot, bar, hist, stem, stairs
and pie.
The example below produces three simple plots. The first is a static plot comparing the
function sin(x) with its approximation x-x3/3. The second is a static plot producing a helix
(spiral) and the third plot is dynamically using the comet command. The plots come up in the
Figure window. They can be printed or copied and pasted into another document if required.
>> % program to explore the use of some simple plotting commands
>> % First example discusses a cubic approximation to sin(x)
>> x = pi*([0:100]/100); % row vector of 101 equally spaced points between 0 and pi
>> hold off % means that the next plot will be drawn on a clean set of
axes
>> plot(x,sin(x),'r*') % plots sin(x) against x using red *'s
Figure T2. 7 Edit Window with a program to demonstrate the animated plot
The Edit Window is essentially a programming text editor, with the features of the languages
of MATLAB being highlighted in different colors. Comments in m-files appear in green,
variables and numbers appear in black, character strings appear in red, and language keywords
appear in blue. Do not create a m-file with the same name as a MATLAB function or command.
To execute the m-file, either type the file name in the command prompt (>>) or press F5. The m-
file tutoria1212.m gives the figure which is shown in Figure T2. 2.
A second type of m-file is a function file which is generated with an editor exactly as the script
file. Students are advised to learn this too.
loop is used to advance time in an obvious way. Note the very important draw now command,
which causes the plot to be put on the screen at each time step, thus allowing the animation to be
seen.
Let us see some more animated plot of set of values using the command ``comet''
>> t = [0:300]/3;
>> comet3(sin(t),cos(t),t)
The resultant plot is shown in Figure T2. 10
6. Plotting is easy in MATLAB, for both real and complex numbers. The basic plot command
will plot a vector yy versus a vector xx. Try the following:
>>xx = [-3 -1 0 1 3 ];
>>yy = xx.*xx - 3*xx;
>>plot( xx, yy )
>>zz =xx + yy*sqrt(-1);
>>plot( zz )
Drop the semicolons, if you want to display the values in the xx, yy, and zz vectors. Use help to
learn how the operation xx.*xx works; compare to matrix multiply.
7. Be sure to understand the colon notation. In particular, observe what the following MATLAB
code will produce:
>>jk1= 2 : 4 : 17
>>jk1= 99 : -1 : 88
>>ttt= 2 : (1/9) : 4
>>tpi=pi * [2 : (-1/9) : 0 ]
8. Extracting or inserting numbers in a vector is very easy to do. Consider the following
definition:
>>xx = [ ones(1,4), [2:2:11], zeros(1,3) ]
>>xx(3:7)
>>length(xx)
>>xx(2:2:length(xx))
Analyse the result echoed from the last three lines of this code.
𝑥(𝑛) = 𝐴𝛼 𝑛
Α is real value. 𝛼 Can be real or complex.
If 0≤ 𝛼 ≤ 1, then the signal x (n) will decay exponentially. If 𝛼 ≥ 1, then the signal x (n) will
grow without bound.
(e) The sinusoidal discrete signal
Mathematically, the sinusoidal discrete signal is written as
𝑥(𝑛) = 𝐴𝑐𝑜𝑠(𝑤𝑜 𝑛 + 𝜑)
Where A is the amplitude, 𝑤𝑜 is the angular frequency and 𝜑 is the phase.
(f) RANDOM SIGNALS
A random signal of length N with samples uniformly distributed in the interval [0,1] can be
generated using the following MATLAB command
𝑥 = 𝑟𝑎𝑛𝑑(1, 𝑁)
Similarly a random signal of length N with samples normally distributed with zero mean and
variance one can be generated using the MATLAB command.
𝑥 = 𝑟𝑎𝑛𝑑𝑛(1, 𝑁)
4. Procedures:
The procedures to develop a Matlab code to generate different discrete-time signals are stated
below for each signal type separately.
Code 1:-
% program 1.1 to simulate the
impulse/unit sample response function
n = -10:20;
n0=0;
% Generate the unit sample sequence
u =n-n0==0;
% Plot the unit sample sequence
stem(n,u);
xlabel('Time index n');
ylabel('Amplitude');
title('Unit Sample Sequence');
axis([-10 20 0 2]);
Code#2:-
% program 1.2 to simulate the impulse/unit sample
response function by using input keyword
clc;
clf;
N=input('unit impulse sequence of length N=');
M=input('unit impulse sequence delayed by M=');
n=-N:M;
% Generate the unit sample
% sequence
u=[zeros(1,N) 1 zeros(1,M)];
% plot of unit sample sequence
stem(n,u)
xlabel('Time index n');
ylabel('Amplitude');
title('unit Sample Sequence');
axis([-10 20 0 1.2]);
grid on;
Define the interval of the unit step function, that is, enter the starting and ending points.
Enter the shift point no.
Plot the sequence.
Write the following code on Matlab M-file and run it.
Code#2:-
% Program 1.3 to generate Unit Step Signal
clc; clear all; close all hidden;
N =input('Enter the length of the sequence (even number) N
: ');
m =input('Enter the location of impulse sample
m : ');
n=[(-N/2):(N/2)];
unit_step=[n>=m];
stem(n,unit_step);
xlabel('Time index n');
ylabel('Amplitude');
title('Unit Step Response')
Figure P1L1. 3 The unit step response: sample output of program 1.3
% Program 1.5
% Generation of a complex exponential sequence
clf;
c = -(1/12)+(pi/6)*i; % define the base which is complex
A = 2; % amplitude of the function
n = 0:40; % time index range
x = A*exp(c*n); % the function defined
subplot(2,1,1);
stem(n,real(x)); % plot real part of x
xlabel('Time index n');ylabel('Amplitude');
title('Real part');
subplot(2,1,2);
stem(n,imag(x)); % plot imaginary part
xlabel('Time index n');ylabel('Amplitude');
title('Imaginary part');
e) Random Signals
One of the applications of digital signal processing is to remove random noise from a
signal which has been corrupted by noise. Let s [n] be the signal corrupted by a random noise d
[n] resulting in the noisy signal x[n] = s[n] + d[n]. The objective is to operate on x [n] to
generate a signal y [n] which is a reasonable approximation to s [n]. This can be done by
averaging the samples of x[n]. This is referred to as moving average filter
𝑦[𝑛] = 1/3(𝑥(𝑛 − 1) + 𝑥[𝑛] + 𝑥(𝑛+))
%Program P1.7
%signal Smoothing by Averaging
clc;
clf;
R=51;
d=0.8*(rand(R,1)-0.5);
m=0:R-1;
s=2*m.*(0.9.^m);
x=s+d';
subplot(2,1,1);
plot(m,d,'r',m,s,'g--',m,x,'b-.'); grid on;
xlabel('Time index n');ylabel('Amplitude');
legend('d[n] ','s[n] ','x[n] ');
x1=[0 0 x];x2=[0 x 0];x3=[x 0 0];
y=(x1+x2+x3)/3;
subplot(2,1,2);
plot(m,y(2:R+1),'r-',m,s,'g--');grid on
legend('y[n] ','s[n] ');
xlabel('Time index n');ylabel('Amplitude');
5. Lab Task
(i) Impulse and unit-step responses
1. Run Programs 1.1 and 1.3 to generate the unit sample and unit step sequences for
different input parameters.
2. What are the purposes of the commands input, stem, and title?
3. Write a matlab code that displays graphically the following discrete-time signals:
(a) x (n)=u(n+4)-u(n-4)
(b) x(n)=δ(n)+δ(n+2)
(ii) Exponential sequences
1. Run Program 1.4 and generate the complex-valued exponential sequence.
2. Which parameter controls the rate of growth or decay of this sequence? Which
parameter controls the amplitude of this sequence?
3. What are the purposes of the operators’ real and imag?
4. What is the purpose of the command subplot?
(iii). Write MATLAB programs to generate the square, triangular and sawtooth wave sequences
of the types shown in Figures below.
1. square wave
2. Background Theory
A causal version of the three-point smoothing filter is given by
𝑦[𝑛] = 1/3(𝑥[𝑛] + 𝑥 [𝑛 − 1] + 𝑥[𝑛 − 2])
Generalizing the above equation we obtain
𝑀−1
1
𝑦[𝑛] = ∑ 𝑥[𝑛 − 𝑘]
𝑀
𝑘=0
This defines a causal M-point smoothing FIR filter. The above equation is also known as a
moving average filter. Program 2.1 illustrates its use in filtering high-frequency components
from a signal composed of a sum of several sinusoidal signals.
% Program 2.1
% Simulation of an M-point Moving Average Filter
% Generate the input signal
n = 0:100;
s1 = cos(2*pi*0.05*n); % A low frequency sinusoid
s2 = cos(2*pi*0.47*n); % A high frequency sinusoid
x = s1+s2;
% Implementation of the moving average filter
M = input('Desired length of the filter = ');
num = ones(1,M);
y = filter(num,1,x)/M;
% Display the input and output signals
clf;
subplot(2,2,1);
plot(n,s1);
axis([0, 100, -2, 2]);
xlabel('Time index n'); ylabel('Amplitude'); title('Signal # 1');
subplot(2,2,2);
plot(n,s2);
axis([0, 100, -2, 2]);
xlabel('Time index n'); ylabel('Amplitude'); title('Signal # 2');
subplot(2,2,3);
plot(n,x);
axis([0, 100, -2, 2]);
xlabel('Time index n'); ylabel('Amplitude'); title('Input Signal');
subplot(2,2,4);
plot(n,y);
axis([0, 100, -2, 2]);
xlabel('Time index n'); ylabel('Amplitude'); title('Output Signal');
axis;
Figure P2L1. 1 The illustration of the moving average filter Program 2.1 .
5. Lab Task:-
1. Run the above program for M = 2 to generate the output signal with x[n] = s1[n]+ s2[n] as the
input. Which component of the input x[n] is suppressed by the discrete time system simulated by
this program?
2. If the system is changed from y[n] =0.5(x[n] + x[n - 1]) to y[n] =0.5(x[n] - x[n - 1]), what
would be its effect on the input x[n] = s1[n] + s2[n]?
3. Run Program 2 .1 for other values of filter length M, and various values of the frequencies of
the sinusoidal signals s1 [n] and s2 [n]. Comment on your results.
A discrete system is time-invariant if shifting the input only causes the same shift in the output.
An LTI system is BIBO stable if and only if its impulse response is absolutely sum able.
ℎ(𝑛) = 0, 𝑛 < 0
3. Materials Required: Matlab Software and Computers.
4. Procedure:
a. Linearity and Non-Linearity:
We now investigate the linearity property of a causal system of described by the following
equation.
Ex:-
𝑦[𝑛] − 0.4𝑦[𝑛 − 1] + 0.75𝑦[𝑛 − 2] = 2.2𝑥[𝑛] + 2.3𝑥[𝑛 − 1] + 2.4𝑥[𝑛 − 2]
%Program P2.2
clc
n = 0:40;
a = 2; b = -3;
x1 = cos(2*pi*0.1*n);
x2 = cos(2*pi*0.4*n);
x = a*x1 + b*x2;
num =[1 0.3 2.4] ;
den = [1 0 -1 0.75 3];
ic = [0 0 0 0]; % Set zero initial conditions
y1 = filter(num,den,x1,ic); % Compute the output y1[n]
y2 = filter(num,den,x2,ic); % Compute the output y2[n]
y = filter(num,den,x,ic); % Compute the output y[n]
yt = a*y1 + b*y2;
d = y - yt; % Compute the difference output d[n]
% Plot the outputs and the difference signal
subplot (4,1,1)
stem(n ,y);
ylabel('Amplitude');title('Output Due to Weighted Input');
subplot(4,1,2)
stem(n,yt);
ylabel('Amplitude');title('Weighted Output');
subplot(4,1,3)
stem(n,d);
xlabel('Time index n');ylabel('Amplitude');title('Difference Signal');
subplot(4,1,4)
plot(n,d);
xlabel('Time index n');ylabel('Amplitude');title('Difference Signal');
%Program P2.3
clc
n = 0:40; D = 10;a = 3.0;b = -2;
x = a*cos(2*pi*0.1*n) + b*cos(2*pi*0.4*n);
xd = [zeros(1,D) x];
num = [2.2 2.3 2.4];
den = [1 -0.4 0.75];
ic = [0 0];% Set initial conditions
% Compute the output y[n]
y = filter(num,den,x,ic);
% Compute the output yd[n]
yd = filter(num,den,xd,ic);
% Compute the difference output d[n]
d = y - yd(1+D:41+D);
% Plot the outputs
subplot(3,1,1)
stem(n,y);
ylabel('mplitude');title('Output y[n]');grid;
subplot(3,1,2)
stem(n,yd(1:41));
ylabel('Amplitude');title(['Output Due to Delayed Input x[n ,
num2str(D),]']);grid;
subplot(3,1,3)
stem(n,d);
xlabel('Time index n'); ylabel('Amplitude');title('Difference
41Signal');grid;
| P a g e DEPARTMENT OF ELECTRICAL AND COMPUTER ENGINEERING by SEREKEBIRHAN
Digital Signal Processing Lab Manual
𝑠(𝑘) = ∑ |ℎ[𝑛]|
𝑛=0
for increasing values of K, and checks the value of |h[K]| at each iteration step. If the value of
|h[K]| is smaller than 10-6, then it is assumed that the sum S(K) has converged and is very
close to S(∞).
%program p2.3
clc;clf;
num=[1 -0.8]; den=[1 1.5 0.9];
N=200;
h=impz(num,den,N+1);
parsum=0;
for k=1:N+1
parsum=parsum+abs(h(k));
if abs(h(k) <10^(-6)),break, end
end
n=0:N;
stem(n,h);
xlabel('Time index n');ylabel('Amplitude');
disp('Value=');
disp(abs(h(k)));
See the difference between the one obtained by filter function and the conv function.
% Program P1.1
clf;
h = [3 2 1 -2 1 0 -4 0 3]; % impulse response
x = [1 -2 3 -4 3 2 1]; % input sequence
y = conv(h,x);
n = 0:14;
subplot (2,1,1);
stem(n,y);
xlabel('Time index n'); ylabel('Amplitude');
title('Output Obtained by Convolution');grid;
x1 = [x zeros(1,8)];
y1 = filter(h,1,x1);
subplot(2,1,2);
stem(n,y1);
xlabel('Time index n'); ylabel('Amplitude');
title('Output Generated by Filtering');grid;
Figure P2L1. 5 linearly convolved output of LTI system to a finite length input.
5. Lab Task
1. Run Program 1.1 to generate y[n] obtained by the convolution of the sequences h[n] and x[n],
and to generate y1[n] obtained by filtering the input x[n] by the FIR filter h[n]. Is there any
difference between y[n] and y1[n]? What is the reason for using x1[n] obtained by zero-padding
x[n] as the input for generating y1[n]?
2. Modify Program 1.1 to develop the convolution of a length-15 sequence h[n] with a length-10
sequence x[n], and repeat question 1. Use your own sample values for h[n] and x[n].
2. Background Theory
The linear convolution possesses difficulty because of the finite word length of the real-time
processors. This difficulty has been solved by the introduction of the circular convolution. The
circular convolution is otherwise called the periodic convolution and it gets repeated at every
sample period, N. Hence, by definition the periodic convolution is written as
∞
5. Lab Task:-
1. Perform the circular convolution of the following. Consider the first element of each sequence
at the index value zero.
Some class of DTFTs that can be expressed in rational form of equation xxx can be evaluated
using Matlab command freqz.
∑𝑀
𝑘=0 𝑏1 𝑒
−𝑗𝜔𝑡
𝑏0 + 𝑏1 𝑒 −𝑗𝜔𝑡 + ⋯ … . 𝑏𝑀 𝑒 −𝑗𝜔𝑡
𝑥(𝑒 𝑗𝜔𝑡 ) = =
∑𝑀
𝑘=0 𝑎𝑖 𝑒
−𝑗𝑘𝑡 𝑎0 + 𝑎1 𝑒 −𝑗𝜔𝑡 + ⋯ … . 𝑎𝑁 𝑒 −𝑗𝜔𝑡
Where k=0,1,2…..M, i=1,2,3…….N and ai and bk are constant coefficients.
In general X(ejω) is a complex function of the real variable ω and can be written as
where
The quantity |X(ejω)| is called the magnitude function and the quantity θ(ω) is called the phase
function , with both functions again being real functions of ω. In many applications, the Fourier
transform is called the Fourier spectrum and, likewise, |X(e jω)| and θ(ω) are referred to as the
magnitude spectrum and phase spectrum, respectively.
The matlab command freqz gives the frequency response of a linear discrete-time system
specified by its transfer function.
Input parameters:
a vector b containing the coefficients of the numerator polynomial bl , for l =0, 1, . . .,M;
a vector a containing the coefficients of the denominator polynomial , ai, for i =0, 1, . . .,
N;
the number n of points around the upper half of the unit circle, or, alternatively, the
vector w of points in which the response is evaluated.
Output parameters:
a vector containing the frequency response;
a vector w containing the frequency points at which the frequency response is evaluated;
With no arguments, freqz plots the magnitude and unwrapped phase of the transfer
function.
% Program 1.1
% Evaluation of the DTFT
clf;
% Compute the frequency samples of the DTFT
w = -4*pi:8*pi/511:4*pi;
num = [2 1];den = [1 -0.6];
H= freqz(num, den, w);
% Plot the DTFT
subplot(2,1,1)
plot(w/pi,real(H));grid
title('Real part of H(e^{j\omega})');xlabel('\omega /\pi');
ylabel('Amplitude');
subplot(2,1,2)
plot(w/pi,imag(H));grid
title('Imaginary part of H(e^{j\omega})');xlabel('\omega /\pi');
ylabel('Amplitude');
pause
subplot(2,1,1)
plot(w/pi,abs(H));grid
title('Magnitude Spectrum |H(e^{j\omega})|');xlabel('\omega /\pi');
ylabel('Amplitude');
subplot(2,1,2)
plot(w/pi,angle(H));grid
title('Phase Spectrum arg[H(e^{j\omega})]');xlabel('\omega /\pi');
ylabel('Phase, radians');
5. Lab Task:-
1. What is the function of pause keyword?
2. Find the frequency response of the system with h (n) =n (0.1)n sin(n) for 0 ≤ ≤ 100. Plot
the magnitude and phase response of the system. Implement it in Matlab.
3. Find the Fourier transform of x(n) = δ(n) + (δ n – 1) + (n δ – 2) + (δ n – 3). Plot the
magnitude and the phase of X(jω).
4. Consider the difference equation 𝑦(𝑛) = 0.1𝑦(𝑛 − 1) + 0.2𝑦(𝑛 − 2) = 𝑥(𝑛) Find the
frequency response and plot its magnitude and phase.
Lab #2:-The Discrete Fourier Transform (DFT) and Inverse DFT Computations
1. Objectives:
To sample signals in frequency domain.
To compute DFT of signals efficiently using fast Fourier Transforms (FFT) algorithms
embedded in Matlab.
To compute circular convolution of two signals in frequency domain.
2. Background Theory
The N-point discrete Fourier transform (DFT) of a finite-length sequence x[n], defined for 0 ≤ n
≤ N − 1, is given by
𝑁−1
% program 2.3
% to compute FFT using DSP function fft
x=input('The given sequence is x(n): ');
X = fft(x); % calculates the FFT X(k) of the vector x(n)
Xs = fftshift(X); % shifts the vector X(k) in symmetric form
Xsm = abs(Xs) ; % magnitude spectrum
Xsp = angle(Xs) ; % phase spectrum
disp ('The FFT of x(n) is: ');
X;
N=length(X);
P=1:N;
stem(P,X),grid
% program 2.4
% to compute FFT using DSP function fft
n = 0:29;
x1 = cos(2*pi*n/10); % 3 periods
x2 = [x1 x1]; % 6 periods
x3 = [x1 x1 x1]; % 9 periods
N = 2048;
X1 = abs(fft(x1,N));
X2 = abs(fft(x2,N));
X3 = abs(fft(x3,N));
F = (0:N-1)/N;
subplot(3,1,1)
plot(F,X1),title('3 periods');
axis([0 1 0 50]);
subplot(3,1,2)
plot(F,X2);
title('6 periods');
axis([0 1 0 50])
subplot(3,1,3)
plot(F,X3);
title('9 periods')axis([0 1 0 50]);
5. Lab Task:-
1. Try to explain step by step how the programs 1.2, 1.3 and 1.4 work.
2. Modify programs 1.4 to accept any arbitrary user data sequences.
3. Run the programs for different input data sequences.
2. Background Theory
The z-transform of the signal x(n) is given by
∞
𝑋(𝑧) = ∑ 𝑥(𝑛)𝑧 −𝑛
𝑛=−∞
% clc
n=[2 -5/6]; % numerator coefficients
d=[1 -5/6 1/6]; % denominator coefficients
[p,q,r]=residuez(n,d) % produces numerator and denominator
(4b) Procedure:
Enter numerator coefficients i.e. P values.
Enter denominator coefficients i.e. q values.
Use residuez command to produce numerator and denominator coefficients for rational
from.
clc
[a,b]=residuez(p,q,r) % produces numerator and denominator
% coefficients for the rational Z-transform
b=
1.0000 -0.8333 0.1667
Hence the rational Z-transform is
5
2−0.8333𝑧 −1 2− 𝑧 −1
𝐻 (𝑧 ) = = 5
6
1
1−0.8333𝑧 −1+0.1667𝑧 −2 1− 𝑧 −1 + 𝑧 −2
6 6
clc
n=[2 -5/6]; % numerator coefficients
d=[1 -5/6 1/6]; % denominator coefficients
roots(n) % display zeros
roots (d) % display poles
zplane(n,d) % displays the pole-zero diagram
ans =
0.4167
ans =
0.5000
0.3333
Hence the region of convergence (ROC) of the given Z-transform is |z |> 1/2.
5. Lab Task:-
1. Express the following Z-transform in the partial fraction expansion form, plot its poles and
zeros, and then determine its ROCs.
2𝑧 4 + 16𝑧 3 + 44𝑧 2 + 56𝑧 + 32
𝐺 (𝑧 ) =
3𝑧 4 + 3𝑧 3 − 15𝑧 2 + 18𝑧 − 12
2. Write a MATLAB program to compute and display the poles and zeros, to compute and
display the factored form, and to generate the pole-zero plot of a z-transform that is as ratio of
two polynomials in z−1. Use this program to analyze G(z),
2 + 5𝑧 −1 + 9𝑧 −2 + 5𝑧 −3 + 3𝑧 −4
𝐺 (𝑧 ) =
2 + 45𝑧 −1 + 2𝑧 −2 + 𝑧 −3 + 𝑧 −4
Another expression for xS( jΩ) follows by noting that the Fourier transform of sa(t) is
∞
2𝜋
sa (𝑗𝛺) = ∑ 𝛿(𝛺 − 𝑘𝛺𝑠 )
𝑇𝑠
𝑛=−∞
∞
1 1
𝑋𝑠 (𝑗𝛺) = 𝑋𝑎 (𝑗𝛺) ∗ 𝑆𝑎 (𝑗𝛺) = ∑ 𝑋𝑎 (𝛺 − 𝑘𝛺𝑠 )
2𝜋 𝑇𝑠
𝑛=−∞
Thus, X(ejω) is a frequency scaled version of ( Ω), with the scaling defined by
𝑤 = 𝛺𝑇𝑠
This scaling, which makes X(ejω) periodic with a period of 2π, is a consequence of time-scaling
that occurs when xs(t) is converted to x(n).
Sampling Theorem: if xa(t) is strictly bandlimited,
𝑋𝑎 (𝑗𝛺)=0 |Ω|>Ω0
Then xa(t) may be uniquely recovered from its samples xa(nT s) if
2𝜋
𝛺= ≥ 2 𝛺0
𝑇𝑠
The frequency Ω is called the Nyquist frequency, and the minimum sampling frequency,
Ω = 2Ω is called the Nyquist rate.
If the signal is sampled below the sampling rate i.e. Ω < 2Ω0 , there is the overlapping of the
shifted replicas of Xa (Ω) . This phenomenon is known as aliasing. When aliasing occurs the
original signal cannot be recovered.
To generate the reconstructed signal ya(t) from x[n], we pass x[n] through an ideal low pass
reconstruction filter that in turn can be implemented according to the bellow equation . h(t) is the
impulse response of the filter.
𝜋𝑡
sin( 𝑇 )
𝑠
ℎ (𝑡 ) = 𝜋𝑡
𝑇𝑠
If this equation is computed at closely spaced values of t, a plot of ya(t) will resemble a
continuous-time signal.
4. Procedure:
% p4.1
% Illustration of the Sampling Process
% in the Time Domain
clc;
t = 0:0.0005:1;
f = 13;
xa = cos(2*pi*f*t);
subplot(2,1,1)
plot(t,xa,'LineWidth',1.5);
xlabel('Time, msec');ylabel('Amplitude');title('Continuous-time signal
x_{a}(t)');
axis([0 1 -1.2 1.2])
subplot(2,1,2);
T = 0.1;
n = 0:T:1;
xs = cos(2*pi*f*n);
k = 0:length(n)-1;
stem(k,xs,'r');
xlabel('Time index n');ylabel('Amplitude');title('Discrete-time signal
x[n]');
axis([0 (length(n)-1) -1.2 1.2])
n = 0:T:1;
xs = cos(2*pi*f*n);
k = 0:length(n)-1;
stem(k,xs,'r');
5.Lab Task:-
4. The plots of the continuous-time signal and its sampled version generated by running Program
P4.1 for the following four values of the sampling period are shown below: T = 0.004 msec, T =
0.02 msec, T = 0.15 msec, T = 0.2 msec. What is your observations? Comment your result.
To study the aliasing effect of signals during sampling process in time domain.
4. Procedure:
Here we will generate a continuous-time equivalent ya(t) of the discrete-time signal x[n]
generated in Program P1.1 to investigate the relation between the frequency of the sinusoidal
signal xa(t) and the sampling period. To generate the reconstructed signal ya(t) from x[n], we
pass x[n] through an ideal low pass reconstruction filter that in turn can be implemented
according to equation (4.12) . If this equation is computed at closely spaced values of t, a plot of
ya(t) will resemble a continuous-time signal.
% Program P4.2
% Illustration of Aliasing Effect in the Time Domain
clc;
T = 0.1;
f = 13;
n = (0:T:1)';
xs = cos(2*pi*f*n);
t = linspace(-0.5,1.5,500)';
ya = sinc((1/T)*t(:,ones(size(n))) - (1/T)*n(:,ones(size(t)))')*xs;
plot(n,xs,'bo',t,ya, 'r','Linewidth',1.5);grid;
xlabel('Time, msec');ylabel('Amplitude');
title('Reconstructed continuous-time signal y_{a}(t)');
axis([0 1 -1.2 1.2]);
5. Lab Task:-
1) Run Program 4.2 to generate both the discrete-time signal x[n] and its continuous time
equivalent ya(t) and display them.
2) What is the range of t and the value of the time increment in Program 4.2? What is the
range of t in the plot? Change the range of t so as to display the full range ya(t) being
computed in the above program and run Program 4.2 again. Comment on the plot
generated after this change.
3) The plots of the continuous-time signal and its sampled version generated by running
Program P4.2 for the following four values of the sampling period are shown below: T =
0.004 msec, T = 0.02 msec, T = 0.15 msec, T = 0.2 msec. What is your observations?
4. Procedure:
The relation between the continuous-time Fourier transform (CTFT) of an arbitrary
bandlimited Continuous-time signal and the discrete-time Fourier transform (DTFT) of the
discrete-time signal is investigated next. In order to convert a continuous-time signal xa(t) into
an equivalent discrete-time signal x[n], the former must be band-limited in the frequency
domain. To illustrate the effect of sampling in the frequency domain we choose an exponentially
decaying continuous-time signal with a CTFT that is approximately bandlimited.
% Program 4.3
% Illustration of the Aliasing Effect
% in the Frequency Domain
clf;
t = 0:0.005:10;
xa = 2*t.*exp(-t);
subplot(2,2,1)
plot(t,xa);grid
xlabel('Time, msec');ylabel('Amplitude');
title('Continuous-time signal x_{a}(t)');
subplot(2,2,2)
wa = 0:10/511:10;
ha = freqs(2,[1 2 1],wa);
plot(wa/(2*pi),abs(ha));grid;
xlabel('Frequency, kHz');ylabel('Amplitude');
title('|X_{a}(j\Omega)|');
axis([0 5/pi 0 2]);
subplot(2,2,3)
T = 1;
n = 0:T:10;
xs = 2*n.*exp(-n);
k = 0:length(n)-1;
stem(k,xs);grid;
xlabel('Time index n');ylabel('Amplitude');
title('Discrete-time signal x[n]');
subplot(2,2,4)
wd = 0:pi/255:pi;
hd = freqz(xs,1,wd);
plot(wd/(T*pi), T*abs(hd));grid; xlabel('Frequency,
kHz');ylabel('Amplitude'); title('|X(e^{j\omega})|'); axis([0 1/T 0 2])
5. Lab Task:-
1. Run Program 4.3 to generate and display both the discrete-time signal and its continuous-time
equivalent, and their respective Fourier transforms. Is there any visible effect of aliasing?
2. Repeat Program 1.3 by increasing the sampling period to 1.5. Is there any visible effect of
aliasing?
2
3. Modify Program 4.3 for the case of 𝑥𝑎 (𝑡) = 𝑒 −𝑖𝜋𝑡 and repeat questions 1 and 2.
4. Time-domain Sampling: Consider the continuous-time signal
𝑒 −2𝑓𝑜 𝑡 , 𝑡 ≥ 0
𝑋𝑎 (𝑡) = {
0, 𝑡 < 0
%ProgramP4_5
%Illustration of Down-Sampling by an Integer Factor
%
close all; clear all; clc
n = 0:49;
m = 0:50*3-1;
x = sin(2*pi*0.042*m);
y = x([1:3:length(x)]);
subplot(2,1,1)
stem(n,x(1:50));axis([0 50 -1.2 1.2]);
title('InputSequence');
xlabel('Timeindexn');
ylabel('Amplitude');
subplot(2,1,2)
stem(n,y);axis([0 50 -1.2 1.2]);
title('OutputSequence');xlabel('Timeindexn');ylabel('Amplitude');
resample. Each function is available with several options. In this section you will study the
decimation and interpolation operation using these functions.
b) Decimator Design and Implementation
Program P10_3 illustrates the use of the M-function decimate in the design and implementation
of a decimator with an integer-valued decimation factor M. In the option utilized in this program,
decimate designs and uses a low pass decimation filter with a stopband edge.
%ProgramP4_6
%Illustration of Decimation Process
clear all; close all; clc
M=input('Down-samplingfactor=');
n=0:99;
x=sin(2*pi*0.043*n)+sin(2*pi*0.031*n);
y=decimate(x,M,'fir');
subplot(2,1,1);
stem(n,x(1:100));
title('InputSequence');
xlabel('Timeindexn');ylabel('Amplitude');
subplot(2,1,2);
m=0:(100/M)-1;
stem(m,y(1:100/M));
title('OutputSequence');xlabel('Timeindexn');ylabel('Amplitude');
Down-samplingfactor=5
%ProgramP4-7
%Illustration of Interpolation Process
%
clear all; close all; clc
L=input('Up-samplingfactor=');
% Generate the input sequence
n=0:49;
x=sin(2*pi*0.043*n)+sin(2*pi*0.031*n);
% Generate the interpolated output sequence
y=interp(x,L);
% Plot the input and the output sequences
subplot(2,1,1);
stem(n,x(1:50));
title('InputSequence');xlabel('Timeindexn');ylabel('Amplitude');
subplot(2,1,2);
m=0:(50*L)-1;
stem(m,y(1:50*L));
title('OutputSequence');xlabel('Timeindexn');ylabel('Amplitude');
Up-samplingfactor=2
% Program P4-8
% Illustration of Sampling Rate Alteration by
% a Ratio of Two Integers
%
close all; clear all; clc
L=input('Up-samplingfactor=');
M=input('Down-samplingfactor=');
n=0:29;
x=sin(2*pi*0.43*n)+sin(2*pi*0.31*n);
y=resample(x,L,M);
subplot(2,1,1);
stem(n,x(1:30));axis([0 29 -2.2 2.2]);
title('InputSequence');
xlabel('Timeindexn');ylabel('Amplitude');
subplot(2,1,2);
m=0:(30*L/M)-1;
stem(m,y(1:30*L/M));axis([0 (30*L/M)-1 -2.2 2.2]);
title('OutputSequence');
xlabel('Timeindexn');ylabel('Amplitude');
Up-samplingfactor=1
Down-samplingfactor=2
Once you obtain partial fraction coefficients Ak, determine the transfer function of IIR digital
filter H(z) as follows
𝑁
𝑇𝑠 𝐴𝐾
𝐻 (𝑧 ) = ∑
1 − 𝑒 𝑠𝑘𝑇𝑠 𝑧 −1
𝑘=1
2 1+𝑧 −1
In other words, evaluate H(s) at 𝑠 = 𝑇 (1+𝑧 −1 )
𝑠
With higher order filter the calculations get very complex. MATLAB contains the function
bilinear and is used to obtain the transfer function H(z) that approximates the analogue transfer
function H(s).
Within the syntax
[zz,pz,kz] = bilinear(zs,ps,ks,fs)
the function converts the s-domain transfer function specified by zs, ps and ks to a z-transform
discrete equivalent obtained from the Bilinear transformation where column vectors zs and ps
specify the zeros and poles, scalar ks specifies the gain and fs is the sampling frequency in Hz.
With the syntax
[numz,denz] = bilinear(nums,dens,fs)
where nums and dens are row vectors containing the numerator and denominator coefficients of
the analogue transfer function H(s), in descending powers of s, the function transforms H(s) to
the z-transform coefficients numz and denz of the IIR digital filter transfer function H(z). The
syntax [Az,Bz,Cz,Dz] = bilinear(As,Bs,Cs,Ds,fs) is a state-space version of the bilinear
transform. Each syntax for the bilinear function accepts an optional additional input argument
that specifies prewarping.
The syntax
[zz,pz,kz] = bilinear (zs,ps,ks,fs,fprewarp)
Applies prewarping before the bilinear transformation so that the frequency responses before and
after mapping match exactly at frequency point fprewarp. The matching point fprewarp is
specified in Hz.
(c) IIR Filter Design Using MATLAB
(i) From the Analogue Prototype to the IIR Digital Filter
In this way of design, analog filter of any type can be used and transformed into IIR digital
equivalent filters using impulse invariance and bilinear transformations. The two transform
MATLAB functions are impinvar and bilinear.
Table P5: 0-1 Analogue Transformation Functions
Frequency Transformation Transformation Function
Lowpass to lowpass [nums,dens]=lp2lp(nums,dens,W0)
[As,Bs,Ds]=lp2lp(As,Bs,Cs,Ds,W0)
Lowpass to highpass [nums,dens]=lp2hp(nums,dens,W0)
[As,Bs,Ds]=lp2hp(As,Bs,Cs,Ds,W0)
Lowpass to bandpass [nums,dens]=lp2bp(nums,dens,W0,BW)
[As,Bs,Ds]=lp2bp(As,Bs,Cs,Ds,W0,BW)
4. Procedure:
Start with a prototype second-order analogue lowpass Butterworth filter.
Convert it to a second-order lowpass analogue Butterworth filter with cut-off frequency
of 200π rad/sec.
Use the Bilinear and the Impulse Invariance transformations to get H(z), the transfer
function of the IIR digital filter.
IIR Impulse invariance and bilinear transformation using direct method:
Figure P5. 1 Magnitude responses of IIR filter using impulse invariance and bilinear
transformation by method I.
Using the Bilinear transformation method, the numerator and denominator coefficients of the
transfer function of the IIR digital second-order filter are
numzb = 0.0640 0.1279 0.0640
denzb = 1.0000 –1.1683 0.4241 and the corresponding IIR filter transfer function is
0.0640𝑧 2 + 0.127𝑧 + 0.0640
𝐻 (𝑧 ) =
𝑧 2 − 1.1683𝑧 + 0.4241
Using the Impulse Invariance method, the numerator and denominator coefficients of the transfer
function of the IIR digital second-order filter are
numzi = 0 0.2449
denzi = 1.0000 –1.1580 0.4112 and the corresponding transfer function of the IIR filter is
0.2449
𝐻 (𝑧 ) =
𝑧 2 − 1.1580𝑧 + 0.4112
b. Method II: Direct Design
Use the MATLAB function : [numz, denz] = butter (n,wn,’ftype’) without ftype, since
the default type is lowpass, and with wn = 0.2 and n= 2 and 6.
Use wn = 0.2 as the normalized frequency because the equivalent cut-off digital
frequency is 200 π(1/1000) = 0.2π.
Normalize, using MATLAB, the digital frequencies to belong to the digital frequency
interval [0 1].
% program 5.2
clf
for n=2:4:6
[numz, denz]=butter(n, 0.2)%the normalized digital frequency is 0.2
%Now we plot the magnitude response of the IIR digital filter
%using the two transformation methods
[H, f]=freqz(numz, denz);
plot(f/pi, abs(H));hold on;
end
title('The Magnitude response using the function butter');
xlabel('frequency in pi units');
axis([0 1 0 1]);
In this case, coefficients of the numerator and the denominator of the transfer function for N = 2
are
numz = 0.0003 0.0020 0.0051 0.0068 0.0051 0.0020 0.0003
denz =1.0000 -3.5794 5.6587 -4.9654 2.5295 -0.7053 0.0838
Figure P5. 2 The magnitude responses of IIR filter using impulse invariance and bilinear
transformation by direct method
The corresponding digital IIR transfer functions are
0.0657𝑧 2 +0.1349𝑧+006557
𝐻 (𝑧 ) = 𝑧 2−1.143𝑧+0.4128
5. Lab Task:-
1. Consider the input continuous signal x(t)=2+ cos(10t) Design a digital second- and sixth-
order IIR low pass Butterworth filter to attenuate the cos(10t) term and pass the dc 2 term.
2. We are trying to eliminate all frequencies that are lower than 100 Hz from the incoming
signal x(t). If the sampling frequency is 1000 Hz, design a digital high pass IIR filter to
accomplish this task. Allow 1 dB for the maximum passband attenuation and 40 dB for the
minimum stopband attenuation.
3. We are interested in passing the term sin(1500t) from the input signal x(t) = sin(10t)
+sin(1500t) + sin(5000t). Design a bandpass IIR Cheby1 digital filter to accomplish this
task. Plot the input signal along with the magnitude response of the filter and its output.
4. We are trying to suppress all frequencies that are higher than 200 Hz and below 400 Hz from
the incoming signal x(t). If the sampling frequency is 2000 Hz (the minimum sampling
should be 800 Hz but sampling at higher rates can give better results), design a digital
bandstop IIR filter to accomplish this task. Use the Cheby2 filter in the design. Use 40 dB for
the minimum allowable ripple in the stopband.
Note: In all questions you have to use Matlab to design the required IIR filters
2. Background Theory
The general input/output equation of a causal FIR filter in the Z-domain is given by:
4. Procedure:
Matlab includes several graphical tools to generate filters. The Signal Processing Tool
(sptool) is an interactive GUI for digital signal processing used to not only analyse signals but
also to design and to analyse filters. You can accomplish these tasks using four GUIs that you
access from within sptool:
The Signal Browser is for analyzing signals. You can also play signals using your
computer’s audio hardware.
The Filter Design and Analysis Tool (fdatool) is available for designing or editing FIR
and IIR digital filters. Most filter design methods available at the command line are also
available in fdatool. Additionally, you can use fdatool to design a filter by using the
Pole/Zero Editor to graphically place poles and zeros on the z-plane.
The Filter Visualization Tool (fvtool) is the proper tool to analyses filter, showing its
characteristics.
The Spectrum Viewer is for spectral analysis. You can use Signal Processing Toolbox
spectral estimation methods to estimate the power spectral density of a signal.
Design a digital FIR lowpass filter by using matlab’s tools few steps.
1) Type sptool at the MATLAB command prompt:
5) To access the filter coefficients of the designed filter go to the sptool window and select
’Export’ from the ’File Menu’.
5. Lab Task:-
1) Design a digital FIR bandpass filter with the following specifications:
Passband: 8-12 kHz
Stopband Ripple: Rs = 80db
Passband Ripple: Rp = 0.001
Transition width: 3kHz
Sampling frequency: fs = 44.1 kHz
Obtain the filter coefficients and frequency response for the above FIR using the Blackman
window method.
2. Design a digital FIR filter for telephony, Specifications for the Transmit Filter:
• attennuation band 1: 0-150 Hz, min. 30 dB attenuation
• pass band: 340 - 3400 Hz, riple max. 2 dB
• attennuation band 2: above 4600 Hz, min. 40 dB attenuation