DSP Journal - BE-08 PDF
DSP Journal - BE-08 PDF
Aim:
Software used:
Scilab / MATLAB
Theory:
Certain discrete time signals are most frequently encountered while studying digital signal
processing. Some of them are generated through software and plotted in this experiment. A brief
description of such signals is given below:
1. Unit Impulse
.
3. Ramp signal
A discrete time ramp signal can be defined as ,
1
ELECTRONICS ENGINEERING DEPARTMENT Jatin Gohil (08)
Digital Signal Processing & Processor VI Semester
4. Exponential signal
2
ELECTRONICS ENGINEERING DEPARTMENT Jatin Gohil (08)
Digital Signal Processing & Processor VI Semester
Program:
3
ELECTRONICS ENGINEERING DEPARTMENT Jatin Gohil (08)
Lab Manual Digital Signal Processing & Processor VI Semester
subplot(3,2,2)
plot2d3(n1,y4')
xlabel('n');
ylabel('amplitude');
title("Unit Step")
//Plotting of Ramp//
x=1:10 //Defining the range of x//
y5 =x //Value of y axis= present value of x//
subplot(3,2,3)
plot2d3(x,y5')
xlabel('n');
ylabel('amplitude');
title("Ramp")
Output Window
4
ELECTRONICS ENGINEERING Department
Lab Manual Digital Signal Processing & Processor VI Semester
5
ELECTRONICS ENGINEERING Department
Lab Manual Digital Signal Processing & Processor VI Semester
Software used::
Scilab, MATLAB
Theory
DFT is widely employed in signal processing and related fields to analyze the
frequencies contained in a sampled signal, to solve partial differential equations, and to
perform other operations such as convolutions. The DFT can be computed efficiently in
practice using a fast Fourier transform (FFT) algorithm.
DFT is a computational tool for performing frequency analysis of discrete time signals.
The mathematical expression is
N −1 −j2πkn
X (k) = ∑ x[n]e N 0,1,2,..........(N-1)
for k =
n=0
Scilab Program:
X=
x=
X=
x=
Software used:
Scilab/ MATLAB.
Theory
Properties of DFT:
● Periodicity
● Linearity
● convolution
If
Then
Procedure:
8
ELECTRONICS ENGINEERING Department
Lab Manual Digital Signal Processing & Processor VI Semester
Scilab Program:
//Periodicity
//Linearity
//Convolution
9
ELECTRONICS ENGINEERING Department
Lab Manual Digital Signal Processing & Processor VI Semester
Output Window:
1) Periodicity Property
Define the value of N8
discrete signal[1 2 3 4 5 6 7 8]
X=
36. + 4.115D-14i - 4. + 9.6568542i - 4. + 4.i - 4. + 1.6568542i - 4. - 4.651D-15i - 4. -
1.6568542i - 4. - 4.i - 4. - 9.6568542i
X1=
36. - 4. + 9.6568542i - 4. + 4.i - 4. + 1.6568542i - 4. - 3.919D-15i - 4. - 1.6568542i - 4. - 4.i -
4. - 9.6568542i
2) Linearity
discrete signal[1 1 1 1 1 1 1 1]
discrete signal[1 2 3 4 5 6 7 8]
X=
184. - 16. + 38.627417i - 16. + 16.i - 16. + 6.627417i - 16. - 1.812D-14i - 16. - 6.627417i -
16. - 16.i - 16. - 38.627417i
Y
184. - 16. + 38.627417i - 16. + 16.i - 16. + 6.627417i - 16. - 1.812D-14i - 16. - 6.627417i -
16. - 16.i - 16. - 38.627417i
3) Convolution
x=
1. 4. 7. 6.
y=
1. 4. 7. 6. 0. 0. 0.
Conclusions: The fft and ifft of a signal is used to verify the properties of DFT.
Experiment – 4:
10
ELECTRONICS ENGINEERING Department
Lab Manual Digital Signal Processing & Processor VI Semester
Aim: To Write a program for finding the order of analog filter for a given set of specification using
Butterworth , Chebyshev approximation.
Requirements
Scilab/MATLAB
Theory: The ideal response of an IIR filter may be approximated using different response
functions. They are Butterworth , Chebyshev approximation. For a given set of filter
specification ,both of the approximations gives a different set of order of the filter. a
comparative study of filter behavior is carried out in this experiment by calculating the order
of individual filter for same set of specification.
Procedure:
1) Enter the following filter specification
stop band frequency
pass band frequency
pass band ripple
stop band ripple
2) Use the formula for finding the order of filter using Butterworth and Chebyshev approximation
methods
3) Compare the order found by each method & comment on the same
4) Compare one of the specification keeping the other three constant observe the effect on order of
filter
Matlab Program:
11
ELECTRONICS ENGINEERING Department
Lab Manual Digital Signal Processing & Processor VI Semester
clc;
Ws=input ('Stop band frequency');%stop band frequency
Wp=input('pass band frequency')%pass band frequency
Ap=input ('attenuation pass band');%pass band ripple
As=input ('attenuation stop band') ;%stop band ripple
a=(10^(0.1*Ap))-1
b=(10^(0.1*As))-1
d=sqrt(b/a)
e=log(d)
f=log (Ws/Wp)
N=e/f
disp('N=')
disp(round(N))
g=acosh(d)
h=acosh (Ws/Wp)
M=g/h
disp('M=')
disp(round(M))
Wn=0.5
disp('The order of filter is');
disp(n);
disp('cut off frequencies');
disp(Wn);
[nums,dens] = butter(n,Wn)%filter coefficient calculation
freqz(nums,dens),
title('magnitude and phase responses of Analog Lowpass Butterworthfilter');
figure
[nums1,dens1] = cheby1(n,Ap,0.6)
title('magnitude and phase responses of Analog Lowpass BChebyshev');
freqz(nums1,dens1)
figure
N=
7
M=
12
ELECTRONICS ENGINEERING Department
Lab Manual Digital Signal Processing & Processor VI Semester
nums =
dens =
nums1 =
dens1 =
Conclusion: For the given set of specification filter order and cut off frequency was calculated for
Butterworth ,Chebyshev.
13
ELECTRONICS ENGINEERING Department
Lab Manual Digital Signal Processing & Processor VI Semester
Aim: To write a programe to design an IIR digital filter starting with digital specifications using
Impulse Invarient method.
Requirements
MATLAB
Theory:
IIR filter design using impulse invariance is one of the IIR digital filter design techniques using
analog filter transfer function. In this method, the analog filter impulse response h(t) is found out
from the analog filter transfer function H a (s) . This impulse response is discretised by sampling it at
regular intervals of ts . Z-transform of these samples is taken to obtain H(z). Thus the impulse
response of the digital filter is same as that of analog filter at the sampling instants and hence the
name impulse invariance technique. This method maps a stable analog function into a stable digital
function. However, due to sampling the j Ω axis in the s plane is not mapped uniquely into the unit
radius circle in the Z plane. Hence , this technique is restricted and used to design only low pass
filters and band pass filters with low resonant frequencies.
Matlab Program:
% EXP 5-Program to design a IIR filter using Impulse Invariance Transformation.
clear all;
clc;
% PART A
wp=input('Enter the pass band frequency');
ws=input('Enter the stop band frequency');
14
ELECTRONICS ENGINEERING Department
Lab Manual Digital Signal Processing & Processor VI Semester
wp1 =
942.4778
ws1 =
4.3982e+03
15
ELECTRONICS ENGINEERING Department
Lab Manual Digital Signal Processing & Processor VI Semester
sys =
2.455e06
-----------------------
s^2 + 2216 s + 2.455e06
Output window:
Aim: To write a programe to design an IIR digital filter starting with digital specifications using
Bilinear Transform method.
Requirements
MATLAB
This is yet another technique of obtaining the digital filter function from an analog filter function.
In this technique the analog differential equation representing the filter system is integrated using
the trapezoidal rule of integration. The s plane to Z plane mapping is obtained by taking the
Z-transform of the resulting difference equation.
Bilinear Transformation maps a stable analog filter function into a stable digital filter
function. Also, the entire j Ω axis in the s-plane ( − ∞ to + ∞ ) is mapped only once into the Z- plane
over the unit radius circle. Hence, it can be used to design all types of digital filters. However, the
transformation function given by Ω = ( 2t ) tan tan (w/2) is highly nonlinear and the frequencies at
the higher end in the analog domain are compressed in the digital domain. This effect is known as
frequency warping.
16
ELECTRONICS ENGINEERING Department
Lab Manual Digital Signal Processing & Processor VI Semester
sampling frequency
Matlab Program:
Ws=(2*pi*ws)/(fs/2);
xp=tan(Wp/2);
xs=tan(Ws/2);
Fpb=(xp*fs)/(4*pi)
Fsb=(xs*fs)/(4*pi)
disp(Fpb);
disp(Fsb);
Wp1=(2*pi*Fpb);
Ws1=(2*pi*Fsb)
[N,wn]=buttord(Wp1,Ws1,Ap,As,'s');
[n,d]=butter(N,wn,'s');
[ni,di]=bilinear(n,d,fs)
sys1=tf(ni,di)
disp(sys1)
[h,f]=freqz(ni,di,1024,fs);
subplot(2,2,1);
plot(f,abs(h));
title('frequency response of Filter')
%pole zero plot
subplot(2,2,2);
zplane(ni,di);
title('Z-Plane of Filter')
Ouput on Command Window
Enter the pass band frequency150
Enter the stop band frequency700
Enter the pass band attenuation in dB3
Enter the stop band attenuation in dB18
Enter Sampling Frequency3000
Fpb =
17
ELECTRONICS ENGINEERING Department
Lab Manual Digital Signal Processing & Processor VI Semester
77.5689
Fsb =
2.2714e+03
77.5689
2.2714e+03
Ws1 =
1.4272e+04
ni =
0.2319 0.2319
di =
1.0000 -0.5363
sys1 =
0.2319 s + 0.2319
-----------------
s - 0.5363
Output window:
18
ELECTRONICS ENGINEERING Department
Lab Manual Digital Signal Processing & Processor VI Semester
Conclusion:
It is verified that the bilinear transformation method is superior as compared to impulse invarient
method.
19
ELECTRONICS ENGINEERING Department
Lab Manual Digital Signal Processing & Processor VI Semester
Experiment – 6:
Aim: To design of IIR Low pass and High Pass digital butterworth Filters and plot magnitude
response and pole zero diagram
Requirements
MATLAB
Theory:
Infinite Impulse Response (IIR) Filters: Another type of filter is the Infinite Impulse Response (IIR)
filter and the Impulse Response of an IIR filter is of infinite duration. The IIR filters have the
feedback, due to which they are also known as Recursive filters.
N is the number of feedback taps in IIR filter and M is the number of feed forward taps
hy IIR Filters: IIR filters are usually used when computational resources are at a premium.
W
However, stable, causal IIR filters cannot have perfectly linear phase, so that IIR filters tend to be
avoided when linearity of phase is a requirement. Also, computational savings that are comparable
to using IIR filters can be achieved for certain design parameters by using multistage or multirate
FIR filter designs. These designs have the advantage of having linear-phase capability, robustness
to quantization, stability, and good pipeline-ability. Another important reason to use IIR filters is
their relatively small group delay compared to FIR filters. This results in a shorter transient
response to input stimuli. Even if we are able to match or surpass the implementation cost of an IIR
filter by using multirate or multistage FIR designs, the transient response of such FIR designs tends
to be much larger than that of a comparable IIR design. However, minimum-phase FIR design can
have group delays that are comparable or even lower than IIR filters that meet the same
specifications.
In this experiment, you will study the different methods of designing the Infinite Impulse Response
(IIR) Filters
Filters are a basic component of all signal processing and telecommunication system. A filter is a
device or process that removes some unwanted components or features from a signal. Filtering is a
class of signal processing used to complete or partial suppression of some aspects of the signal.
Most often, this means to remove some frequencies and not others in order to suppress the
interfacing signals and reduce the background noise.
20
ELECTRONICS ENGINEERING Department
Lab Manual Digital Signal Processing & Processor VI Semester
Types of Filters:
In signal processing, the filters can be of four types, i.e. Lowpass Filters, Highpass Filter, Bandpass
Filters, and Bandstop Filters.
Lowpass Filters:
An ideal Lowpass filter is the one that allows to pass all frequency components of a signal below a
designated cutoff frequency wc, and rejects to pass all frequency components of a signal above wc
.Its frequency response satisfies.
Highpass Filters:
An ideal Highpass filter is the one that allows to pass all frequencycomponents of a signal above a
designated cutoff frequency wc , and rejects to pass all frequency components of a signal below
wc
.Its frequency response satisfies
Procedure:
1) Enter the following filter specification
stop band frequency
pass band frequency
pass band ripple
stop band ripple
2) Normalize the edge frequencies.
4) For the order, design Low pass and band High filter using MATLAB function
MATLAB Program:
clc;
clc;
Ws=input ('Stop band frequency');%stop band frequency
disp('n');
disp(n);
[b,a]=butter(n,Wn,'low');
%frequency plot
[h,f]=freqz(b,a,1024,Fs);
subplot(3,2,1);
plot(f,abs(h));
%pole zero plot
subplot(3,2,2);
zplane(b,a);
Wsh=input ('Stop band frequency');%stop band frequency
%highpass
[n,Wn]=buttord(Wph/Fs,Wsh/Fs,Aph,Ash);
disp('order of butterworth filter');
disp('n');
disp(n);
[b,a]=butter(n,Wn,'high');
%frequency plot
[h,f]=freqz(b,a,1024,Fs);
subplot(3,2,3);
plot(f,abs(h));
%pole zero plot
subplot(3,2,4);
zplane(b,a);
Wp =
100
n
22
ELECTRONICS ENGINEERING Department
Lab Manual Digital Signal Processing & Processor VI Semester
3
Stop band frequency300
Wph =
100
attenuation pass band3
attenuation stop band25
n
2
Conclusion: Digital Butterworth Low pass and High pass filter are designed and characteristics are
plotted.
Experiment – 7:
23
ELECTRONICS ENGINEERING Department
Lab Manual Digital Signal Processing & Processor VI Semester
Aim: To design of IIR Band pass and Band stop digital butterworth Filters and plot magnitude
response and pole zero diagram
Requirements
MATLAB
Theory
Bandpass Filters: An ideal Bandpass filter is the one that allows to pass all frequency components
of a signal within a certain range, and rejects to pass all frequency components of a signal outside
of that range. Its frequency response satisfies:
Bandstop Filters: An ideal Bandstop filter is the one that rejects to pass all frequency components
of a signal within a certain range, and allows to pass all frequency components of a signal outside
of that range. Its frequency response satisfies:
rocedure:
P
1) Enter the following filter specification
4) For the order, design band pass and band stop filter using MATLAB function
5) Plot the frequency response and pole zero diagram.
MATLAB Program:
clc;
clc;
Wsl=input('Enter the lower stop band frequency')%stop band frequency
Wsh=input('Enter the upper stop band frequency')%stop band frequency
Wpl=input('Enter the lower pass band frequency')%pass band frequency
Wph=input('Enter the upper pass band frequency')%pass band frequency
%Bandpass
Wsl1=input('Enter the lower stop band frequency')%stop band frequency
Wsh1=input('Enter the upper stop band frequency')%stop band frequency
Wpl1=input('Enter the lower pass band frequency')%pass band frequency
Wph1=input('Enter the upper pass band frequency')%pass band frequency
Ap=input ('attenuation pass band');%pass band ripple
As=input ('attenuation stop band') ;%stop band ripple
Wp1=[Wpl1 Wph1]/Fs
Ws1=[Wsl1 Wsh1]/Fs
[n,Wn]=buttord(Wp1,Ws1,Ap,As);
disp('order of butterworth filter');
disp('n');
disp(n);
[b,a]=butter(n,Wn);
%frequency plot
[h,f]=freqz(b,a,1024,Fs);
subplot(3,2,3);
plot(f,abs(h));
title('frequency response of Band Pass Filter')
%pole zero plot
subplot(3,2,4);
zplane(b,a);
title('Z-Plane of Band Pass Filter')
25
ELECTRONICS ENGINEERING Department
Lab Manual Digital Signal Processing & Processor VI Semester
Wsl =
75
Wsh =
175
Wpl =
100
Wph =
150
Wp =
0.2000 0.3000
Ws =
0.1500 0.3500
Passband
Wsl1 =
100
Wsh1 =
150
Wpl1 =
75
Wph1 =
175
27
ELECTRONICS ENGINEERING Department
Lab Manual Digital Signal Processing & Processor VI Semester
1) To check the linear phase condition and classify the given filter into type I, II, III,IV based
on the impulse response.
2) To study the magnitude and phase response of the filter.
Requirements
MATLAB.
Theory: The filter is supposed to operate with a defined pass band and a stop band. An ideal filter
must have constant gain and uniform delay for all the frequencies in pass band. The group delay is
the derivative of the phase angle with respect to frequency. That is,
Matlab Program:
clc;
close all;
28
ELECTRONICS ENGINEERING Department
Lab Manual Digital Signal Processing & Processor VI Semester
clear all;
hn=input('Input the impulse response seuence h(n)');%Get impulse response from user
N=length(hn) % order of the filter
%find out Symmetry of filter
hf=fliplr(hn);
if(hn==hf)
ANS1=0;
disp('symmetric')
elseif(hn==-hf)
ANS1=1;
disp('Asymmetric')
else
ANS1=2;
disp('Not a valid Linear phase filter')
end
ylabel('Amplitude');
title('Frequency responce');
subplot(223)
plot(w,abs(Hf));
xlabel('frequency');
ylabel('Amplitude');
title('Magnitude responce');
subplot(224)
plot(w,angle(Hf));
xlabel('frequency');
ylabel('phase');
title('Phanse responce');
Input the impulse response seuence h(n)[1/12 1/6 1/6 -1/6 -1/6 -1/12]
hn =
Columns 1 through 6
N=
Asymmetric
even
Type =
Transfer function:
0.08333 + 0.1667 z^-1 + 0.1667 z^-2 - 0.1667 z^-3 - 0.1667 z^-4 - 0.08333 z^-5
p=
0 0 0 0 0
z=
30
ELECTRONICS ENGINEERING Department
Lab Manual Digital Signal Processing & Processor VI Semester
EXPERIMENT -9: Finite Impulse Response (FIR) filter design using Window Technique
Aim: Write a Program to design an FIR low pass filter using window function.
Requirements: MATLAB.
indowing technique is one of the methods used for FIR filter design. An ideal filter
W
function in the frequency domain gives infinitely stretched response in the time domain. This
response is made finite by multiplying it with suitable window function. The response is made
causal by shifting the required number of samples towards right. There are different window
functions along with the corresponding frequency response is studied in this experiment.
Hamming Window:
w(n)=0.54+0.46*cos(2*pi*n/(m-1)) for n=0 to m-1
Hanning Window:
w(n)=0.5+0.5*cos(2*pi*n/(m-1)) for n=0 to m-1
Blackman Window:
w(n)=0.42+0.5*cos(2*pi*n/(m-1))+0.08*cos(4*pi*n/(m-1)) for n=0 to m-1
MATLAB Program:
clc;
M=input('enter the length of the filter=');
disp(M);
n=( (-(M-1)/2)) : 1 :((M-1)/2);
wa=0:0.1:pi;
fc=0.5;
%rectangular window
w=[ones(1,M)];
subplot(4,3,1);
stem(n,w)
title('Rectangular Window')
W=freqz(w,1,wa);
subplot(4,3,2);
plot(wa,abs(W))
h=fir1(M-1,fc,w);
H=freqz(h,1,wa);
subplot(4,3,3);
plot(wa,abs(H));
%hamming window
w1=0.54+(0.46*cos(2*pi*n/(M-1)));
subplot(4,3,4)
stem(n,w1);
title('Hamming Window')
W1=freqz(w1,1,wa);
subplot(4,3,5)
plot(wa,abs(W1));
h=fir1(M-1,fc,w1);
H=freqz(h,1,wa);
subplot(4,3,6);
plot(wa,abs(H));
%hanning window
w2=0.5+0.5*cos(2*pi*n/(M-1));
subplot(4,3,7)
stem(n,w2);
title('Hanning Window')
W2=freqz(w2,1,wa);
subplot(4,3,8)
plot(wa,abs(W2));
h=fir1(M-1,fc,w2);
H=freqz(h,1,wa);
subplot(4,3,9);
plot(wa,abs(H));
%blackman window
w3=0.42+0.5*cos((2*pi*n)/(M-1))+0.08*cos((4*pi*n)/(M-1));
subplot(4,3,10)
stem(n,w3);
title('Blackman Window')
W3=freqz(w3,1,wa);
subplot(4,3,11)
plot(wa,abs(W3));
h=fir1(M-1,fc,w3);
H=freqz(h,1,wa);
subplot(4,3,12);
plot(wa,abs(H));