DSP 18eel67 Final
DSP 18eel67 Final
DSP 18eel67 Final
VI SEMESTER
NAME: .................................
USN: ...................................
SEM: ....................................
BATCH: ...............................
Prepared by:
Department
To become one among the best departments in M1: To provide learner-centric environment through
engineering and research arena through quality education and training
professional faculty and state of art laboratories M2: To lay the foundation for research by fortifying
and to make the students successful engineers peers & establishing incubation center.
with good ethics. M3: To develop the overall personality of the students to
face the challenges of the real world.
SL
Criteria Marks Allocation Marks
No.
1 Conduction/Execution of Experiment(C) (30% of Total Max..Mks) 9
2 Analysis & Interpretation of Results(A) (30% of Total Max..Mks) 9
3 Report writing & Documentation ( R ) (20% of Total Max..Mks) 6
4 Viva (V) (20% of Total Max..Mks) 6
SL
Criteria Marks Allocation Marks
No.
1 Procedure write-up on given Experiment (20% of Total Max..Mks) 2
2 Conduction / Execution of Experiment (30% of Total Max. Mks) 3
3 Analysis & Interpretation of Results (30% of Total Max. Mks) 3
4 Viva (20% of Total Max. Mks) 2
PO 1 2 3 4 5 6 7 8 9 10 11 12
CO1 3 2 3 2 2 1
CO2 3 2 3 2 2 1
CO3 3 2 3 2 2 1
CO4 3 2 3 2 2 1
PSO's Mapping
CO-NO
1 2 3 4
CO1 3
CO2 3
CO3 3
CO4 3
Table of Contents
Sl. No. Particulars Page No.
1 Introduction to MATLAB 1
2 Sampling Theorem 13
3 Impulse Response 17
4 Linear Convolution 21
5 Circular convolution 25
6 N point DFT 32
7 Linear and circular convolution 36
8 Difference equation 41
9 Implement FFT for given sequence 47
10 Design & implementation of IIR filter Design. 50
11 Design & implementation of FIR filter using window function 60
You can find a MATLAB icon on the desktop or from the start menu. By double clicking the
icon you can invoke the MATLAB command window.
1. COMMAND window
2. GRAPHICS or FIGURE window
3. EDITOR window
• The output of all the graphics commands typed in the command window are flushed to the
graphics or figure window.
• The user can create as many
• figure windows as the system memory will allow.
3. EDITOR WINDOW:
• This is where you write, edit, create, and save your own programs in files called ‘m-Files’.
• MATLAB provides its own built in editor.
1. M-files.
2. MAT-files.
3. MEX-files.
1. M-FILES:
They are standard ASCII text files with an .m extension to the file name. There are two types of m-files
namely script file and function file.
2. MAT-FILES:
These are binary data files, with a .mat extension to the file name. MAT files are created by MATLAB
when you save the data with the save command. The data is written in a special format that only
MATLAB can read.
3. MEX_FILES:
These are MATLAB callable FORTRAN and c programs with an .mex extension to the filename.
10. stem (t,x):- This instruction will display a figure in discrete form.
11. Subplot: This function divides the figure window into rows and columns Subplot (2 2 1) divides the
figure window into 2 rows and 2 columns 1 represent number of the figure.
1 2
(2 2 1) (2 2 2)
3 4
(2 2 3) (2 2 4)
Subplot (3,1,3)
1 (3,1,1)
2 (3,1,2)
3(3,1,3)
12 Filter
Syntax: y = filter(b,a,X)
Description: y = filter(b,a,X) filters the data in vector X with the filter described by numerator
coefficient vector b and denominator coefficient vector a. If a(1) is not equal to 1, filter normalizes the
filter coefficients by a(1). If a(1) equals 0, filter returns an error.
13. Impz
Description: [h,t] = impz(b,a,n) computes the impulse response of the filter with numerator coefficients
b and denominator coefficients a and computes n samples of the impulse response when n is an integer
(t = [0:n-1]'). If n is a vector of integers, impz computes the impulse response at those integer locations,
starting the response computation from 0 (and t = n or t = [0 n]).If, instead of n, you include the empty
vector for the second argument, the number of samples is computed automatically by default.
Syntax: w = conv(u,v)
Description: w = conv(u,v) convolves vectors u and v. Algebraically, convolution is the same operation
as multiplying the polynomials whose coefficients are the elements of u and v.
15.Disp
Syntax: disp(X)
Description: disp(X) displays an array, without printing the array name. If X contains a text string, the
string is displayed. Another way to display an array on the screen is to type its name, but this prints a
leading "X=," which is not always desirable. Note that disp does not display empty arrays.
16.xlabel
Syntax: xlabel('string')
17. ylabel
Syntax : ylabel('string')
18.Title
Syntax : title('string')
Description: title('string') outputs the string at the top and in the center of the current axes.
19. grid on
Syntax : grid on
clc;
clear all;
close all;
fs = 2000;
f = 50;
t = 0:1/fs:(1/f);
x = sin(2*pi*f*t);
plot(t,x);
title('sine wave');
xlabel('time in sec');
ylabel('amplitude');
Sample Explanation
clc; % clears the command window
clear all; % clears all variables
close all; % existing figure windows will be closed
fs = 2000; % sampling frequency
f = 100; % signal frequency
t = 0:1/fs:(2/f); % generation of the time sequence for sine wave
x = sin(2*pi*f*t); % sine wave generation using sine function
plot(t,x); % the sine wave is displayed in a separate plot window
title('sine function')
Program Waveform
clc;
clear all;
close all;
fs = 2000;
f = 50;
t = 0:1/fs:(1/f);
x = sin(2*pi*f*t);
subplot(1,3,1)
plot(t,x);
title('sine function')
xlabel('time');
ylabel('magnitude');
y1= 2*x;
subplot(1,3,2);
plot(t,y1);
title('2x(t)')
xlabel('time');
ylabel('magnitude');
y2= 0.5*x;
subplot(1,3,3);
plot(t,y2);
title('x(t)/2')
xlabel('time');
ylabel('magnitude');
8. A mixed frequency sine signal having the frequencies 10, 30 and 60Hz.
• close all; 2
• t = 0:.001:0.5;
1.5
• x=sin(2*pi*t*10)+sin(2*pi*t*30)
+sin(2*pi*t*60); 1
• plot(t,x); 0.5
•
Amplitude
• xlabel('Time'), -0.5
ylabel('Amplitude');
-1
-1.5
-2
-2.5
0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 0.45 0.5
Time
Sampling: Is the process of converting a continuous time signal into a discrete time signal. It is the first
step in conversion from analog signal to digital signal.
The sampling operation can be represented by a switch as shown in Fig. 1. The switch is closed
for a very short interval of time τ (ideally, τ = 0), once every T seconds during which the signal is
available at the output. For the input x(t), the output xs(t) = x(nT), n = 0,±1, ±2, ±3, …… and x(nT) is a
sampled sequence of x(t), where T is called the sampling period or sampling interval. It is the time
interval between successive samples and the sampling frequency is given by fs = (1/T) Hz. The switch
used for sampling purpose will be an electronic switch.
x(t) x(n)
NYQUIST RATE OF SAMPLING: Nyquist rate of sampling is the theoretical minimum sampling
rate at which a signal can be sampled and still be reconstructed from its samples without any distortion.
Nyquist rate = 2 fm, where fm is the maximum frequency present in the signal. A signal sampled at
greater than Nyquist rate is said to be over sampled and a signal sampled at less than its Nyquist rate is
said to be under sampled.
Sampling is a process of converting a continuous time signal (analog signal) x(t) into a discrete
time signal x[n], which is represented as a sequence of numbers. (A/D converter)
Converting back x[n] into analog is the process of reconstruction. (D/A converter)
Example 1: Determine the Nyquist rate for the analog signal x(t) is sampled using a sampling rate
of 300Hz. x(t) = 3 cos 100πt − 6 sin 400πt + 4 cos 60πt.
tfinal=0.05;
t=0:0.00005:tfinal; % define time vector .05/.00005=1000 sample pts
fd=input('Enter desired analog frequency'); %200 Hz
%Generate analog signal
xt=sin(2*pi*fd*t);
%simulate condition for under sampling i.e., fs1<2*fd
fs1=1.3*fd;
%define the time vector for under sampling
n1=0:1/fs1:tfinal; % define time vector .05/.00384=13 sample pts
xn=sin(2*pi*n1*fd); %Signal reconstruction
%plot the analog & reconstructed signals
subplot(3,1,1);
plot(t,xt,'b',n1,xn,'r*-');
title('undersampling plot');
%condition for Nyquist sampling fs2=2*fd
fs2=2*fd;
n2=0:1/fs2:tfinal; %define the time vector 05/.00384=13 sample pts
xn=sin(2*pi*fd*n2); %Signal reconstruction
%plot the analog & reconstructed signals
subplot(3,1,2);
plot(t,xt,'b',n2,xn,'r*-');
title('Nyquist plot');
%condition for oversampling
fs3=5*fd;
n3=0:1/fs3:tfinal; %define the time vector 05/.001=50 sample pts
xn=sin(2*pi*fd*n3); %Signal reconstruction
%plot the analog & reconstructed signals
subplot(3,1,3);
plot(t,xt,'b',n3,xn,'r*-');
title('Oversampling plot');
xlabel('time');
ylabel('amplitude');
legend('analog','discrete')
Output:
A/D converter operates at a specified sampling rate, termed as fs .
This fs determines the upper limit of the input signal frequency, fmax.
From Nyquist sampling theorem the requirement of sampling frequency is given by fs ≥ 2fmax
where fs = sampling frequency, fmax = Highest frequency component of analog signal.
Say if fs = 20 kHz, then fmax should be ≤10 KHz.
If the input signal has frequency components greater than fmax, then these components are converted
into low-frequency ones, resulting in a noise called aliasing noise.
The signal in Example 1 is sampled using a sampling rate of 300Hz.
After sampling the signal is reconstructed from the samples. Determine the frequency components in the
reconstructed analog signal. Comment on the aliasing error.
Sol:
x(t) with freq components of 30 Hz, 50 Hz & 200 Hz is sampled at 300 Hz (fs).
30 Hz & 50 Hz are less than fs/2 (i.e., 150 Hz) not affected by aliasing present as 30 Hz and 50Hz
respectively in the reconstructed analog signal.
200Hz component of x(t) is above fs/2 (folding frequency) and is changed by the aliasing effect.
In the reconstructed analog signal the 200 Hz component will be aliased into
200-fs = 200 − 300 = −100 Hz. (the minus sign represents a phase shift of 180◦)
In summary the reconstructed analog signal has the frequency components 30 Hz, 50 Hz and 100 Hz.
Result: Sampling theorem is verified for under, Nyquist rate and over sampling using MATLAB.
Staff Signature:
AIM: To find Impulse response of a first order and second order system.
Question: Write the Matlab code to find the impulse response of a given second order system whose
difference equation is given below.
THEORY: A discrete time system performs an operation on an input signal based on predefined criteria
to produce a modified output signal. The input signal x(n) is the system excitation, and y(n) is the
system response. The transform operation is shown as,
A discrete time LTI system (also called digital filters) as shown in Fig above represented by a linear
constant coefficient difference equation,
Once the impulse response h(n) is obtained, the response y(n) of the LTI system for any input x[n] can
be obtained by applying the convolution sum.
Given the difference equation or H(z), impulse response of LTI system is found using filter or impz
MATLAB functions.
If the difference equation contains past samples of output, i.e., y[n-1], y[n-2], etc , then its impulse
response is of infinite duration (IIR). For such systems the impulse response is computed for a large
value of n, say n=100 (to approximate n=∞).
If both y[n] and x[n] are finite then the impulse response is finite (FIR).
Given only the input sequence x[n] and the output sequence y[n], we can find the impulse function h[n]
by using the inverse operation deconv.
conv operation convolves 2 sequences x[n] and h[n] to obtain the output y[n]. The deconvolution
operation is valid only if the LTI system is ‘invertible’.
Output:
The given difference equation is y(n) - y(n-1) + 0.9y(n-2) = x(n)
The output sequence y(n) of the system=[1 -1 0.9]
The input sequence of the system=[1]
The impulse response of the system is=
1.0000 -1.0000 0.9000
the verified output sequence is
1.0000 -1.0000 0.9000
y (n) + 3 y(n-1) - 0.12 y(n-2) = x(n) + 0.2 x(n-1) – 1.5 x(n-2) take Z transform on both the sides
Y(Z) + 3Z-1Y(Z) - 0.12Z-2Y(Z) = X(Z) +0.2 Z-1X(Z) – 1.5 Z-2 X(Z)
Y(Z) [ 1 + 3Z-1 - 0.12 Z-2 ] = X(Z) [1 +0.2 Z-1 – 1.5 Z-2]
clc;
% enter the input and output coefficients
b=input('Enter the coefficients of x(n): ');
a=input('Enter the coefficients of y(n): ');
N=input('Enter the number of samples of impulse response desired: ');
% Calculate Impulse Response using/IMpZ futption:
% [1.1,T] = IMPZ(B,A,N) computes N leMples:9f the impulse response
% coefficients B and A from difference egeation representation.
[h,t] = impz(b,a,N);
%Plot and Display impulse response co-efficients:
stem(t,h);
title('Impulse Response Plot');
ylabel('h(n)');
xlabel('n');
disp('Impulse response coefficients:');
disp(h);
Output:
Enter the coefficients of x(n):[1 0.2 -1.5]
Enter the coefficients of y(n): [1 3 -0.12]
Enter the number of samples of impulse response desired:5
Impulse Response coefficients are
1.0000
-2.8000
7.0200
-21.3960
65.0304
Results: Verify the impulse response of the given system for the given LTI System.
Staff Signature:
LINEAR CONVOLUTION
THEORY:
Convolution is a formal mathematical operation, just as multiplication, addition, and integration.
Addition takes two numbers and produces a third number, while convolution takes two signals and
produces a third signal.
Convolution is used in the mathematics of many fields, such as probability and statistics. In
linear systems, convolution is used to describe the relationship between three signals of interest: the
input signal, the impulse response, and the output signal.
A discrete-time system performs an operation on an input signal based on a predefined criterion to
produce a modified output signal. The input signal x(n) is the system excitation and the output signal
y(n) is the system response. The transform operation is as shown below:
If the input to the system is a unit impulse, i.e. x(n) = δ(n), then the output of the system is known as
impulse response denoted by h(n) where h(n) = T{δ(n)}.
The system is assumed to be initially relaxed, i.e. the system has zero initial conditions.
For any arbitrary sequence x(n) can be represented as a weighted sum of discrete impulses as
For a linear time invariant system, if the input sequence x(n) and the impulse response h(n) are given,
the output sequence y(n) is given by
Output of exp3:
2 7 2 -1 11 -6
Result: Linear convolution of the sequences is found and the results are verified in MATLAB.
Staff Signature:
CIRCULAR CONVOLUTION
AIM: To perform circular convolution of given sequences using (a) the convolution summation formula
(b) the matrix method and (c) Linear convolution from circular convolution with zero padding.
THEORY: The convolution property of DFT says that, the multiplication of DFTs of two sequences is
equivalent to the DFT of the circular convolution of the two sequences.
Let DFT [x1(n)] = X1(k) and DFT [x2(n)] = X2(k), then by the convolution property
X1(k)X2(k) = DFT{x1(n) x2(n)}.
Circular convolution: Let x1(n) and x2(n) are finite duration sequences both of length N with DFT’s
X1(k) and X2(k). Convolution of two given sequences x1(n) and x2(n) is given by the equation,
x3(n) = IDFT[X3(k)]
N-1
x3(n) = ∑ x1(m) x2((n-m))N
m=0
Output:
clc;
close all;
clear all;
x=input('enter the 1st sequence x(n)=');
h=input('enter the 1st sequence h(n)=');
N1=length(x);
N2=length(h);
N=max(N1,N2);
h=[h,zeros(1,N-N2)]
x=[x,zeros(1,N-N1)]
x1=transpose(x);
h1=transpose(h);
temp=h1;
for i= 1:(N-1);
temp=circshift(temp,1);
h1=horzcat(h1,temp);
end
y=h1*x1; % Matrix multiplication
disp('convolution y(n)= x(n)*h(n)=');
disp(y);
clc;
clear all;
close all;
x=input('enter the input sequence x(n)=');
h=input('enter the impulse response sequence h(n)=');
N1=length(x);
N2=length(h);
N=N1+N2-1; %% Length of sequence for linear convolution
h=[h,zeros(1,N-N2)] %% Zero padding
x=[x,zeros(1,N-N1)]
y=cconv(x,h,N); %% Circular convolution function
disp('Given sequence');
disp('x(n)=');
disp(x);
disp('h(n)=');
disp(h);
disp('Linear convolution y(n)= x(n)*h(n)=');
disp(y);
Results: Perform the circular convolution for the given sequences for all the three cases successfully
and verify both the theoretical and practical results
Staff Signature:
AIM: To compute n-point DFT of a given sequence and to plot magnitude and phase spectrum.
The DFT is important for two reasons. First it allows us to determine the frequency content of a signal
that is to perform spectral analysis. The second application of the DFT is to perform filtering operation
in the frequency domain.
The sequence of N complex numbers x0,..., xN−1 is transformed into the sequence of N complex numbers
X0, ..., XN−1 by the DFT according to the formula:
N-1
X(k) = ∑x(n)e-j2πnk/N k = 0,1, …. N-1
n=0
close all;
clear;
x=input('enter the time sequence');
N=input('enter the no.of points of DFT');
for k=0:N-1
X(k+1)=0;
for n=0:length(x)-1
X(k+1)= X(k+1) + x(n+1)* exp (-j*2*pi*n*k/N);
end
end
n=0:length(x)-1;
stem(n,x);
title('time sequence');
xlabel('n');
ylabel('x(n)');
k=0:N-1;
figure
subplot(2,1,1);
stem(k,abs(X));
title('magnitude response');
xlabel('k');
ylabel('mag(X(k))');
subplot(2,1,2);
stem(k,angle(X));
title('phase response');
xlabel('k');
ylabel('phase(X(k))');
abs(X)
angle(X)
OUTPUT:
enter the time sequence [1 2 3 4]
enter the no.of points of DFT 4
ans =
ans =
Result: DFT of the given sequence is found and the results are verified using MATLAB.
Staff Signature:
THEORY: Linear convolution is the basic operation to calculate the output for any linear time invariant
system given its input and its impulse response. Circular convolution is the same thing but considering
that the support of the signal is periodic (as in a circular).
The circular convolution, also known as cyclic convolution, of two aperiodic functions (i.e.
Schwartz functions) occurs when one of them is convolved in the normal way with a periodic
summation of the other function. That situation arises in the context of the Circular
convolution theorem.
The DFT supports only circular convolution. When two numbers of N-point sequence are circularly
convolved, it produces another N-point sequence. For circular convolution, one of the sequence should
be periodically extended. Also the resultant sequence is periodic with period N.
The linear convolution of two sequences of length N1 and N2 produces an output sequence of
length N1 + N2 – 1. To perform linear convolution using DFT, both the sequences should be converted
to N1 + N2 – 1 sequences by padding with zeros. Then take N1 + N2 – 1-point DFT of both the
sequences and determine the product of their DFTs. The resultant sequence is given by the IDFT of the
product of DFTs. [Actually the response is given by the circular convolution of the N1 + N2 – 1
sequences].
Let x(n) be an N1-point sequence and h(n) be an N2-point sequence. The linear convolution of x(n) and
h(n) produces a sequence y(n) of length N1 + N2 – 1. So pad x(n) with N2 – 1 zeros and h(n) with N1 –
1 zeros and make both of them of length N1 + N2 – 1.
Let X(k) be an N1 + N2 – 1-point DFT of x(n), and H(k) be an N1 + N2 – 1-point DFT of h(n). Now,
the sequence y(n) is given by the inverse DFT of the product X(k) H(k).
y(n) = IDFT {X(k)H(k)}
This technique of convolving two finite duration sequences using DFT techniques is called fast
convolution. The convolution of two sequences by convolution sum formula is called direct convolution
or slow convolution.
The term fast is used because the DFT can be evaluated rapidly and
efficiently using any of a large class of algorithms called Fast Fourier Transform (FFT).
close all;
clear;
x= input('enter the first sequence');
h= input('enter the second sequence');
L1=length(x);
L2=length(h);
N= L1 +L2 -1;
X=fft(x,N);
H=fft(h,N);
Y= X.*H;
y=ifft(Y,N)
n=0:L1-1;
subplot(3,1,1);
stem(n,x);
title('First sequence');
xlabel('n');
ylabel('x(n)');
n=0:L2-1;
subplot(3,1,2);
stem(n,h);
title('second sequence');
xlabel('n');
ylabel('h(n)');
n=0:N-1;
subplot(3,1,3);
stem(n,y);
title('linear convolution sequence');
xlabel('n');
ylabel('y(n)');
y=
close all;
clear;
x= input('enter the first sequence');
h= input('enter the second sequence');
L1=length(x);
L2=length(h);
N= max(L1,L2);
X=fft(x,N);
H=fft(h,N);
Y= X.*H;
y=ifft(Y,N)
n=0:N-1;
subplot(3,1,1);
stem(n,x);
title('First sequence');
xlabel('n');
ylabel('x(n)');
subplot(3,1,2);stem(n,h);
title('second sequence');
xlabel('n');
ylabel('h(n)');
subplot(3,1,3);
stem(n,y);
title('linear convolution sequence');
xlabel('n');
ylabel('y(n)');
Result: The result for given sequence for circular and linear convolution using DFT and IDFT was
computed and verified.
Staff Signature:
THEORY:
To solve the difference equation, first it is converted into algebraic equation by taking its Z-
transform. The solution is obtained in z-domain and the time domain solution is obtained by taking its
inverse Z-transform.
The system response has two components. The source free response and the forced response. The
response of the system due to input alone when the initial conditions are neglected is called the forced
response of the system. It is also called the steady state response of the system. It represents the
component of the response due to the driving force. The response of the system due to initial conditions
alone when the input is neglected is called the free or natural response of the system. It is also called the
transient response of the system. It represents the component of the response when the driving function
is made zero. The response due to input and initial conditions considered simultaneously is called the
total response of the system.
For a stable system, the source free component always decays with time. In fact a stable system
is one whose source free component decays with time. For this reason the source free component is also
designated as the transient component and the component due to source is called the steady state
component.
When input is a unit impulse input, the response is called the impulse response of the system and
when the input is a unit step input, the response is called the step response of the system.
Systems may be continuous-time systems or discrete-time systems. Discrete-time systems may be FIR
(Finite Impulse Response) systems or IIR (Infinite Impulse Response) systems.
FIR systems are the systems whose impulse response has finite number of samples and IIR systems are
systems whose impulse response has infinite number of samples. Realization of a discrete-time system
means obtaining a network corresponding to the difference equation or transfer function of the system.
If the discrete-time system is described by difference equation, the time invariance can be found by
observing the coefficients of the difference equation.
If all the coefficients of the difference equation are constants, then the system is time-invariant. If even
one of the coefficient is function of time, then the system is time-variant.
Now, Y(z) /X(z) = H(z) is called the transfer function of the system or the system function. The frequency response of a
jω
system is obtained by substituting z = e in H(z).
Output: exp7b
Length of response required=25
Result: Solution of the difference equation is found and obtained the various responses.
Staff Signature:
AIM: To obtain the DFT and IDFT of a given sequence by using FFT
THEORY:
The N-point DFT of a sequence x(n) converts the time domain N-point sequence x(n) to a frequency
domain N-point sequence X(k). The direct computation of an N-point DFT requires N x N complex
multiplications and N(N – 1) complex additions. Many methods were developed for reducing the
number of calculations involved. The most popular of these is the Fast Fourier Transform (FFT), a
method developed by Cooley and Turkey. The FFT may be defined as an algorithm (or a method) for
computing the DFT efficiently (with reduced number of calculations). The computational efficiency is
achieved by adopting a divide and conquer approach. This approach is based on the decomposition of an
N-point DFT into successively smaller DFTs and then combining them to give the total transform.
Based on this basic approach, a family of computational algorithms was developed and they are
collectively known as FFT algorithms. Basically there are two FFT algorithms; Decimation in- time
(DIT) FFT algorithm and Decimation-in-frequency (DIF) FFT algorithm.
From the above equations for X(k) and x(n), it is clear that for each value of k, the direct computation of
X(k) involves N complex multiplications (4N real multiplications) and N – 1 complex additions (4N – 2
complex additions are required. In fact the DFT and IDFT involve the same type of computations.
Program Code:
Output:
enter the given time domain sequence x(n)=[1 1 1 1]
enter the length of DFT = 8
X = Columns 1 through 5
4.0000 + 0.0000i 1.0000 - 2.4142i 0.0000 + 0.0000i 1.0000 - 0.4142i 0.0000 + 0.0000i
Columns 6 through 8
1.0000 + 0.4142i 0.0000 + 0.0000i 1.0000 + 2.4142i
Columns 1 through 5
4.0000 + 0.0000i 1.0000 - 2.4142i 0.0000 + 0.0000i 1.0000 - 0.4142i 0.0000 + 0.0000i
Columns 6 through 8
1.0000 + 0.4142i 0.0000 + 0.0000i 1.0000 + 2.4142i
Result: Obtain the DFT and IDFT of a given sequence by using FFT and verify the results successfully.
Staff Signature:
AIM: Design of FIR filters of Low pass and high pass filter using Matlab commands
DESCRIPTION: Digital filters refers to the hardware and software implementation of the mathematical
algorithm which accepts a digital signal as input and produces another digital signal as output whose
wave shape, amplitude and phase response has been modified in a specified manner. Digital filter play
very important role in DSP. Compare with analog filters they are preferred in number of application due
to following advantages.
1. Truly linear phase response
2. Better frequency response
3. Filtered and unfiltered data remains saved for further use.
There are two types of digital filters.
1. FIR (finite impulse response) filter
2. IIR (infinite impulse response) filter
Filters are of two types—FIR and IIR.: The type of filters which make use of feedback connection to get
the desired filter implementation are known as recursive filters. Their impulse response is of infinite
duration. So they are called IIR filters. The types of filters which do not employ any kind of feedback
connection are known as non-recursive filters. Their impulse response is of finite duration. So they are
called FIR filters. IIR filters are designed by considering all the infinite samples of the impulse response.
The impulse response is obtained by taking inverse Fourier transform of ideal frequency response. There
are several techniques available for the design of digital filters having an infinite duration unit impulse
response. The popular methods for such filter design use the technique of first designing the digital filter
in analog domain and then transforming the analog filter into an equivalent digital filter because the
analog filter design techniques are well developed.
Advantages of Digital Filters:
1. The values of resistors, capacitors and inductors used in analog filters change with temperature. Since
the digital filters do not have these components, they have high thermal stability.
2. In digital filters, the precision of the filter depends on the length (or size) of the registers used to store
the filter coefficients. Hence by increasing the register bit length (in hardware) the performance
characteristics of the filter like accuracy, dynamic range, stability and frequency response tolerance, can
be enhanced.
RESULT: The IIR low pass butter worth filter & high pass butter worth filter, low pass Chebyshev
bandpass filter and low pass Butterworth band stop filter is verified for the given specifications is
obtained.
Staff Signature:
AIM: To implementation of FIR filters to meet the given specifications for low pass, high pass filter
Band pass and Band stop filter
THEORY:
A filter is a frequency selective system. Digital filters are classified as finite duration unit impulse
response (FIR) filters or infinite duration unit impulse response (IIR) filters, depending on the form of
the unit impulse response of the system. In the FIR system, the impulse response sequence is of finite
duration, i.e., it has a finite number of non-zero terms. The IIR system has an infinite number of non-
zero terms, i.e., its impulse response sequence is of infinite duration. IIR filters are usually implemented
using recursive structures (feedback-poles and zeros) and FIR filters are usually implemented using non-
recursive structures (no feedback-only zeros). The response of the FIR filter depends only on the present
and past input samples, whereas for the IIR filter, the present response is a function of the present and
past values of the excitation as well as past values of the response.
The following are the main advantages of FIR filters over IIR filters:
1. FIR filters are always stable.
2. FIR filters with exactly linear phase can easily be designed.
3. FIR filters can be realized in both recursive and non-recursive structures.
4. FIR filters are free of limit cycle oscillations, when implemented on a finite word
length digital system.
5. Excellent design methods are available for various kinds of FIR filters.
The disadvantages of FIR filters are as follows:
1. The implementation of narrow transition band FIR filters is very costly, as it requires considerably
more arithmetic operations and hardware components such as multipliers, adders and delay elements.
2. Memory requirement and execution time are very high.
FIR filters are employed in filtering problems where linear phase characteristics within the pass band of
the filter are required. If this is not required, either an FIR or an IIR filter may be employed. An IIR
filter has lesser number of side lobes in the stop band than an FIR filter with the same number of
parameters. For this reason if some phase distortion is tolerable, an IIR filter is preferable. Also, the
Results: Design and Implementation of FIR Filters Using different Window Functions can be obtained
successfully.
Staff Signature:
Theory: The frequency-sampling method for FIR filter design is perhaps the simplest and most direct
technique imaginable when a desired frequency response has been specified. It consists simply of
uniformly sampling the desired frequency response, and performing an inverse DFTto obtain the
corresponding (finite) impulse response. The results are not optimal, however, because the response
generally deviates from what is desired between the samples. When the desired frequency-response
is under sampled, which is typical, the resulting impulse response will be time aliased to some extent. It
is important to evaluate the final impulse response via a simulated DTFT (FFT with lots of zero
padding), comparing to the originally desired frequency response.
In frequency sampling method of filter design, we begin with the desired frequency response
specification Hd(ω), and it is sampled at N-points to generate a sequence H(k) which corresponds to the
DFT coefficients. The N-point IDFT of the sequence H(k) gives the impulse response of the filter h(n).
The Z-transform of h(n) gives the transfer function H(z) of the filter.
Result: Realization of FIR filters can be done by using frequency sampling technique successfully.
Staff Signature:
Aim: To Design and realize IIR and FIR filters using Direct form, Cascade and Parallel form.
Theory: To process signals, we have to design and implement systems called filters (or spectrum
analyzers in some contexts). The filter design issue is influenced by such factors as the type of the filter
(i.e., IIR or FIR) or the form of its implementation (structures). IIR filters as designed, can be modeled
by rational system functions or, equivalently, by difference equations.
IIR FILTER STRUCTURES
The system function of an IIR filter is given by
where bn and an are the coefficients of the filter. We have assumed without loss of generality that a0 =1.
The order of such an IIR filter is called N if aN ≠ 0. The difference equation representation of an IIR
filter is expressed as
The order of the filter is M − 1, and the length of the filter (which is equal to the number of coefficients)
is M. The FIR filter structures are always stable, and they are relatively simple compared to IIR
structures.
Furthermore, FIR filters can be designed to have a linear-phase response, which is desirable in some
applications.
We will consider the following four structures:
1. Direct form: In this form the difference equation is implemented directly as given.
2. Cascade form: In this form the system function H(z) is factored into 2nd-order factors, which are
then implemented in a cascade connection.
b0 =
0.7000
cb =
-1.6471
0.2186
ca =
-0.9000
0.8000
r=
0.3441
0.5859
p=
-0.9000
0.8000
k=
0.7000
Interpolation is the process of increasing the sample rate in dsp whereas decimation is the
opposite of this that is, it is the process of decreasing the sample rate in dsp.
10. Define Signal.
A signal is defined as any physical quantity that varies with time, space or any other independent
variable or variables.
11. Define system.
A system is a physical device (i.e., hardware) or algorithm (i.e., software) that performs an
operation on the system.
12. What is static and dynamic system? Give examples.
A discrete time system is called static (or memory less), if its output at any instant depends on
the input sample at the same time (but does not depend on past or future samples). If the
response depends on past depends on past or future samples, then the system is called dynamic
system.
13. What is analog signal?
The analog signal is a continuous function of an independent variable such as time, space etc. the
analog signal is defines for every instant of the independent variable and so the magnitude of
analog signal is continuous in the specified range. Here both the magnitude of the signal and the
independent variable are continuous.
14. Define unit step sequence.
The discrete-time unit step sequence u(n) is defined as:
Procedure
1.Click on the Experiment tab SIMULATOR It will open the workspace.
2.See the movie in experiment page by pressing help button ? to understand how the following steps are
to be executed.
3.In the workspace click on Browse Blocks BROWSE BLOCKS.to understand how the following steps
are to be executed.
4.Drag Sinewave Generator in the left side of the workspace. Click it to parameterize the sinusoidal
signal output. Make amplitude = 3V, frequency = 19 Hz, phase=0 angle.
5.Drag Sampling Block in the workplace. Place it after Sinewave Generator to its right. Click it to
parameterize. Make sampling frequency =40 Hz. It will show no. of sample as 80 for display. The
display is conformed for 2 sec.
8.Connect sinewave generator O/P to I/O of sampler by clicking at both blocks and a link will appear.
9.Similarly connect sampler O/P to one of the I/O of scope.
10.Click somewhere in the middle of the link connecting signal generator & sampler. Keep clicking at
bends till you connect it to the other input of the scope.
12.Move the cursor from one sample to another by draging the slider provide along the x-axis and you
will find sample values in the boxes at bottom left part of the window. Note the first 15 values in a note
book. This 15 values will go as table 1 in your report.
13.In this window, you can change parameters like frequency, amplitude and phase angle of sinusoidal
signal generator & sampling frequency.
14.Change the sinusoidal signal generator O/P amplitude to 1.5V and note 1st 15 values. This will form
Table 2 in your report. In your observation & discussion part of the reporting, you have to compare
Table 1 and Table 2.
15.Change sampling frequency to 43 Hz and amplitude of sinusoidal signal generator at 1V. Note first
15 readings to from Table 3. Compare Table 1 and Table 3
16.Make sampling frequency 40Hz, amplitude of sinusoidal signal generator 10V, phase=30. Table 1st
reading to from Table 4. Compare Table 1 and Table 4.
Procedure
1.Click on the simulator tab SIMULATOR It will open the workspace.
2.See the movie in experiment page by pressing help button to understand how the different steps, as
mentioned next, are to be executed..
3.User controls like filter selection, no. of samples in the ideal filter in time domain, cutoff frequency,
window length (filter order) and window type selection are given to compare the effect of different
windows for designing FIR filters.
4.In this experiment we have provided two types of filters Lowpass and Highpass filters. The sampling
frequency is set to 5000 Hz, you can vary cut-off frequency (fa) from 1000 Hz to 3000 Hz and window
length (Filter order M) from 0 to N. You can choose following window functions: Rectangular, Barlett,
Hamming, Hanning, Blackman and Kaiser windows. If you choose Kaiser window function there is a
parameter called a through which you can change shape of the Kaiser window.
Fig-1
5.Graph 1 plots the impulse response of the filter (Green) in time domain with a time shift of M/2 and
Window function (Red) . A slider is given along the x-axis by this you can read sample by sample value
for impulse response of the filter
Fig-2
6.Graph 2 plots the magnitude spectrum of FIR filter scale the x-axis range from 0 to 5000 Hz. Here
also a slider is provided along the x-axis by which you can read the values at different frequencies. A
check box is provided at right top corner on Graph 2 to switch between magnitude spectrum in Decibel
and absolute value.
Fig-3
7.Graph no. 3 showing the input signal before and after passing through the filter. In the same graph you
can observe the frequency response of the output signal just by checking the checkbox provides
Fig-4
Fig-5
8.While changing the window function you can see the window function expressions on the top right
half of the experiment space. Similarly a text box is provide on the top right hand side from this you can
copy the final filter difference equation to design your filter on hardware or software.
Fig-6
9.You can choose between sine or square signal as input signal and select input signal frequency.
10.When experiment loads first time the default values are set in all user controls. Initially for the
Lowpass filter fs = 5000 Hz, fa = 1000 Hz and M = 50. Rectangular window is being selected by
default. Square wave is the input by default and its frequency if 100 Hz.
11.Keeping filter cutoff frequency constant change the input signal frequency and note down input
signal and output signal peak to peak values. Which will give you table no. 1 for your report generation.
12.Similarly, choose Highpass filter and repeat the step 10 -12 to note down another set of data which
will give you Table no. 2.
13.Now change the window function and do the earlier steps which will give you number of tables.
14.From each table of data you have input and output signal peak to peak values, compute the gain in
decible and plot the gain Vs frequency plot which will give you the same plot what you have with filter
frequency response (Graph 2).
15.Use take snapshot button to take the screenshot of the experiment space.
16.Complete the Observation and discuss the results in report generation.
17.Then click Yes I have finished my Experiment button to submit your report.
fig-1
5.Graph 1 plots the filter frequency response and pole zero plot. Two radio buttons has been provided to
change the plot from frequency response to pole zero plot vice versa. For frequency response plot you
can choose between magnitude or phase response or both by selecting the corresponding checkbox
given below the plot. In pole zero plot mode you will get the filter coefficients you can use these filter
coefficients for filter designing in any other software or programming.
fig-2
6.Here we have taken sum of two sinusoidals of different frequencies (60Hz & 190Hz) as input so that
user can easily understand the filter operation by choosing appropriate cutoff frequencies.
7.Graph 2 and 3 plots input and output signal respectively and also the corresponding frequency domain
plots. Here we have given two radio buttons so that user can change from time domain to frequency
domain plot.