KEMBAR78
DSP Lab | PDF | Discrete Fourier Transform | Sampling (Signal Processing)
0% found this document useful (0 votes)
12 views45 pages

DSP Lab

The Digital Signal Processing Lab manual outlines the syllabus, objectives, and experiments for B.Tech ECE students at JNTUH. It includes instructions for students and teachers, detailing the procedures for conducting experiments using MATLAB and DSP hardware. Key experiments include generating waveforms, calculating DFT/IDFT, and implementing various filters and processes.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views45 pages

DSP Lab

The Digital Signal Processing Lab manual outlines the syllabus, objectives, and experiments for B.Tech ECE students at JNTUH. It includes instructions for students and teachers, detailing the procedures for conducting experiments using MATLAB and DSP hardware. Key experiments include generating waveforms, calculating DFT/IDFT, and implementing various filters and processes.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 45

DIGITAL SIGNAL PROCESSING LAB: MANUAL

Department of ECE

INCHARGES

A.JHANSI RANI
List of Contents

1. JNTUH syllabus.
2. Dos and Don’ts.
3. Course objectives and outcomes.
4. Basic Introduction
5. List of Experiments
JAWAHARLAL NEHRU TECHNOLOGICAL UNIVERSITY HYDERABAD

III Year B.Tech. ECE - II Sem


LTPC
0 03 2
JNTUH Syllabus
DIGITAL SIGNAL PROCESSING LAB

The programs shall be implemented in software (Using MATLAB / Lab view / C programming/
Equivalent) and hardware (Using TI / Analog devices / Motorola / Equivalent DSP processors).

1. Generation of Sinusoidal waveform / signal based on recursive difference equations.

2. Histogram of white Gaussian noise and uniformly distributed noise


3. To find DFT / IDFT of given DT signal.
4. To find frequency response of a given system given in Transfer Function/ Differential
equation form.
5. Obtain Fourier series coefficients by formula and using FET and compare for half sine wave

6. Implementation of FFT of given sequence.


7. Determination of Power Spectrum of a given signal(s).
8. Implementation of LP FIR filters for a given sequence/signal.
9. Implementations of HP IIR filter for a given sequence/signal.
10. Generation of narrow band signal through filtering.
11. Generation of DTMF signals.
12. Implementation of Decimation Process.
13. Implementation of Interpolation Process.
14. Implementation of I/D sampling rate converters.
15. Impulse response of first order and second order systems.

Note: - Minimum of 12 experiments has to be conducted.


JAWAHARLAL NEHRU TECHNOLOGICAL UNIVERSITY HYDERABAD

III Year B.Tech ECE - II Sem

DIGITAL SIGNAL PROCESSING LAB

Cycle I

1. Generation of Sinusoidal waveform / signal based on recursive difference equations.


2. To find DFT / IDFT of given DT signal.
3. To find frequency response of a given system given in Transfer Function/ Differential
equation form.
4. Implementation of FFT of given sequence.
5. Determination of Power Spectrum of a given signal(s).
6. Implementation of LP FIR filters for a given sequence.

Cycle II:
7. Implementations of HP IIR filter for a given sequence/signal.
8. Generation of narrow band signal through filtering.
9. Implementation of Decimation Process.
10. Implementation of Interpolation Process.
11. Implementation of I/D sampling rate converters.
12. Impulse response of first order and second order systems.

Additional experiments:
13. Generation of DTMF signals.
INSTRUCTIONS / Do’s and Don’t

Instruction to Students:-
1. Do not handle any equipment without reading the instructions /Instruction manuals.
2. Observe type of sockets of equipment power to avoid mechanical damage.
3. Strictly observe the instructions given by the Teacher/ Lab Instructor.
4. It is mandatory to come to lab in a formal dress (Shirts, Trousers, ID card, and Shoes for boys).
Strictly no Jeans for both Girls and Boys.
5. It is mandatory to come with observation book and lab record in which previous experiment should
be written in Record and the present lab‘s experiment in Observation book.
6. Observation book of the present lab experiment should be get corrected on the same day
and Record should be corrected on the next scheduled lab session.
7. Mobile Phones should be Switched OFF in the lab session.
8. Students have to come to lab in-time. Late comers are not allowed to enter the lab.
9. Prepare for the viva questions. At the end of the experiment, the lab faculty will ask the viva
Questions and marks are allotted accordingly.
10. Bring all the required stationery like graph sheets, pencil & eraser, different color pens etc. for
the lab class.

Instructions to Laboratory Teachers:-

1. Observation book and lab records submitted for the lab work are to be checked and
signed before the next lab session.
2. Students should be instructed to switch ON the power supply after the connections are
checked by the lab assistant / teacher.
3. The promptness of submission should be strictly insisted by awarding the marks accordingly.

4. Ask viva questions at the end of the experiment.


5. Do not allow students who come late to the lab class.
6. Encourage the students to do the experiments innovatively.
COURSE OBJECTIVES AND OUTCOMES

Objectives:

1. To generate the elementary signals/ waveforms.

2. To Calculate and Plot DFT / IDFT of given DT signal and prove it theoretical.

3. To plot frequency response of a given LTI system.

4. To Implement FFT of a given sequence.

5. To determine and plot the Power Spectrum of a given signal(s).

6. To Plot Magnitude and Phase of LP FIR filter for any given sequence.

7. To Plot Magnitude and Phase of HP IIR filter for a given sequence.

8. To generate Sinusoidal signal through filtering.

9. To Implement Decimation Process of any given sequence.

10. To Implement Interpolation Process of any given sequence.

11. To Implement I/D sampling rate converters.

12. To plot the Impulse response of first order and second order systems

Learning Outcomes:

The student will be:

1.Able to generate elementary signals/ waveforms and perform arithmetic operations on signals.
2.Able to Calculate and Plot DFT / IDFT of given DT signal.
3.Able to plot frequency response of a given system and verify the properties of LTI system.
4.Able to Implement FFT of given sequence and identify the reduction of computations using FFT.
5.Able to Implement LP FIR filter for a given sequence and calculate the filter coefficients.
6.Able to Implement HP IIR filter for a given sequence.
7.Able to generate Narrowband signal through filtering.
8.Able to Implement Decimation Process and vary (decrease) the sampling rate.
9.Able to Implement Interpolation Process and vary (increase) the sampling rate.
10. Able to Implement I/D sampling rate converters and identify the importance of multi rate sampling.
11. Able to determine the Power Spectrum of a given signal(s) and demonstrate the importance of
frequency domain.
12. Able to generate impulse response of first order and second order systems .
Introduction
Starting MATLAB:

After logging into your account, you can enter MATLAB by double-clicking
on the MATLAB shortcut icon (MATLAB 7.0.4) on your Windows desktop.
When you start MATLAB, a special window called the MATLAB desktop
appears. The desktop is a window that contains other windows. The major
tools within or accessible from the desktop are:
 The Command Window
 The Command History
 The Workspace
 The Current Directory
 The Help Browser

 The Start button


 Figure 1.1: The graphical interface to the MATLAB workspace When
MATLAB is started for the first time, the screen looks like the one that
shown

 in the Figure 1.1. This illustration also shows the default configuration of
the MATLAB desktop. You can customize the arrangement of tools and
documents to suit your needs.

 Now, we are interested in doing some simple calculations. We will assume


that you have sufficient understanding of your computer under which
MATLAB is being run. You are now faced with the MATLAB desktop on
your computer, which contains the prompt (>>) in the Command Window.
Usually, there are 2 types of prompt:

 >> For full version

 EDU> for educational version

 Note: To simplify the notation, we will use this prompt, >>, as a

standard prompt sign, Though our MATLAB version is for

educational purpose.

 Using MATLAB as a calculator

 As an example of a simple interactive calculation, just type the expression you


want to
 evaluate. Let’s start at the very beginning. For example, let’s suppose you
want to calculate the expression, 1 + 2 × 3. You type it at the prompt
command (>>) as follows,

 >> 1+2*3

 ans = 7
 You will have noticed that if you do not specify an output variable, MATLAB
uses a

 default variable ans, short for answer, to store the results of the current
calculation. Note that the variable ans is created (or overwritten, if it is
already existed). To avoid this, you may assign a value to a variable or
output argument name. For example

 >> x = 1+2*3

 x =7

 Will result in x being given the value 1 + 2*3=7. This variable name can
always

 be used to refer to the results of the previous computations.


Therefore, computing 4 result in

 >> 4*x

 ans =28.0000

 Before we conclude this minimum session, Table 1.1 gives the

partial list of arithmetic Operators.

 Basic arithmetic

operators Symbol

Operation Example

 + Addition 2+3

 - Subtraction 2-3

 * Multiplication 2*3

 / Division 2/3

Quitting MATLAB
 To end your MATLAB session, type quit in the Command

Window, or select File MATLAB in the desktop main menu.

Getting started

After learning the minimum MATLAB session, we will now learn to use some
additional operations.

Creating MATLAB variables

MATLAB variables are created with an assignment statement. The syntax of variable

assignment is Variable name = a value (or an expression)

For example,

>> x = expression

Where expression is a combination of numerical values, mathematical operators,


variables, and function calls. On other words, expression can involve:
 manual entry
 built-in functions
 user-defined functions

Overwriting variable

Once a variable has been created, it can be reassigned. In addition, if you do not
wish to see the intermediate results, you can suppress the numerical output by
putting a semicolon (;) at the end of the line. Then the sequence of commands
looks like this:

>> t = 5;

>> t = t+1

t =6

Common Procedure to all Programs in MATLAB


1.Click on the MATLAB Icon on the desktop.

2.MATLAB window open.

3.Click on the ‘FILE’ Menu on menu bar.

4.Click on NEW M-File from the file Menu.

5.An editor window open, start typing commands.

6.Now SAVE the file in directory.

7.Then Click on DEBUG from Menu bar and Click Run.


EXP NO 1: GENERATION OF SINUSOIDAL WAVE FORM/ SIGNAL BASED
ON RECURSIVE DIFFERENCE EQUATIONS

AIM: Generation of Sinusoidal Wave form/ Signal based on recursive difference


equations

SOFTWARE USED: MATLAB7.0

PROGRAM:
clc;
clear all;
close all;
b=[1];
a=[+1,-1,0.9];
n=0:3:100;
%generating impulse signal
x1=(n==0);
y1=filter(b,a,x1);
subplot(3,1,1);
stem(n,y1);
xlabel('n');
ylabel('y1(n)');
title ('impulse response');
%generating step signal
x2=(n>0);
%step response
y2=filter(b,a,x2);
subplot(3,1,2);
stem(n,y2);
xlabel('n');
ylabel('y2(n)');
title('step response');
%generating sinusoidal signal
t=0:0.1:2*pi;
x3=sin(t);
%sinusoidal response
y3=filter(b,a,x3);
subplot(3,1,3);
stem(t,y3);
xlabel('n');
ylabel('y3(n)');
title('sin response');

Result: Hence we generated Standard Wave forms/ Signal based on recursive


difference equations
VIVA QUESTIONS:

1. Define impulse signal

2. Define ramp signal

3. Define unit step signal

4. Define exponent ional signal

5. Define sinusoidal signal

6. Define C.T.S

7. Define D.T.S.

8. Compare C.T.S & D.T.S

9. Define Stem, Plot, Plot3,fplot, ezplot, linspace, flyplr, grid, mesh and legend

10. Draw the C.T.S & D.T.S diagrams


EXP NO. 2: TO FIND DFT / IDFT OF A GIVEN DT SIGNAL.

AIM: To write a program to find DFT /IDFT of given DT signal

SOFTWARE USED: MATLAB7.0

PROGRAM:
%program to perform N-point DFT of the given discrete time sequence
%
clc;
clear all;
N=input('Enter the length of sequence');
j=sqrt(-1);
xn=input('Enter input sequence');
xk=zeros(1,N);
for k=0:1:N-1
for n=0:1:N-1
xk(k+1)=xk(k+1)+xn(n+1)*exp(-j*2*pi*k*n/N);
end
end
disp('The DFT sequence is,');xk
disp('Magnitude sequence is,');
magxk=abs(xk)
disp('Phase sequence is,');
phaxk=angle(xk)
wk=0:1:N-1;
subplot(2,1,1);
stem(wk,magxk);
title('Magnitude Spectrum');
xlabel('k');ylabel('magnitude');
subplot(2,1,2);
stem(wk,phaxk);
title('Phase Spectrum');
xlabel('k');ylabel('phase');
INPUT VALUES:

Enter the length of sequence[4]

Enter input sequence[1 1 2 3]

The DFT sequence is,

xk =

7.0000 -1.0000 + 2.0000i -1.0000 - 0.0000i -1.0000 - 2.0000i

Magnitude sequence is,

magxk =

7.0000 2.2361 1.0000 2.2361

Phase sequence is,

phaxk =

0 2.0344 -3.1416 -2.0344

OUTPUT WAVE FORM:


Magnitude Spectrum
8

6
magnitude

0
0 0.5 1 1.5 2 2.5 3
k
Phase Spectrum
4

2
phase

-2

-4
0 0.5 1 1.5 2 2.5 3
k
PROGRAM:
%program to find the IDFT%
clear all;
clc;
N=input('Enter the length of inverse DFT');
i=sqrt(-1);
xk=input('Enter input sequence');
xn=zeros(1,N);
for k=0:1:N-1
for n=0:1:N-1
xn(n+1)=xn(n+1)+(xk(k+1)*exp(i*2*pi*k*n/N))/N;
end
end
disp('The iDFT sequence is,');xn
INPUT VALUES:

Enter the length of inverse DFT4


Enter input sequence [7.0000 -1.0000 + 2.0000i -1.0000 - 0.0000i -1.0000 - 2.0000i]

OUTPUT VALUES:

The IDFT sequence is,

xn = 1.0000 1.0000 + 0.0000i 2.0000 - 0.0000i 3.0000 - 0.0000i

RESULT: Hence we generated the DFT /IDFT of given DT signal.


VIVA QUESTIONS:

1. How to calculate output of DFT using MATLAB?


2. Where DFT is used?
3. What is the difference between DFT and IDFT?
4. How to compute maximum length N for a circular convolution using DFT
and IDFT.(what is command).
5. Explain the function of twiddle factor?
6. Give the practical application DFT & IDFT?
7. Explain the role of DFT & IDFT when the signal converted from the
time domain to frequency domain?
8. Draw all elementary standard discrete time signals.
9. Differentiate between causal and Non causal system.
10.How can you compute Fourier transform form Z-transform ?
EXP NO.3:TO FIND FREQUENCY RESPONSE OF A GIVEN SYSTEM GIVEN
IN TRANSFER FUNCTION/DIFFERENTIAL EQUATION FORM

AIM: To find Frequency response of a given System given in Transfer


Function/Differential equation form.

SOFTWARE USED: MATLAB7.0

THEORY:- The frequency response is a representation of the system's response to


sinusoidal inputs at varying frequencies. The output of a linear system to a sinusoidal
input is a sinusoid of the same frequency but with a different magnitude and phase. Any
linear system can be completely described by how it changes the amplitude and phase of
cosine waves passing through it. This information is called the system's frequency
response. Since both the impulse response and the frequency response contain complete
information about the system, there must be a one-to-one correspondence between the
two. Given one, you can calculate the other. The relationship between the impulse
response and the frequency response is one of the foundations of signal processing: A
system's frequency response is the Fourier Transform of its impulse response Since h [ ] is
the common symbol for the impulse response, H [ ] is used for the frequency response.

PROGRAM:
%Frequency Response of I order%
clc;
clear all;
b=input('enter the num coff');
a=input('enter the den coff');
w=0:0.01:pi;
h=freqz(b,a,w);
subplot(2,1,1);
plot(w/pi,abs(h));
xlabel('normalised freq');
ylabel('magnitude');
grid;
subplot(2,1,2);
plot(w/pi,angle(h));
xlabel('normalised freq');
ylabel('phase in radus');
grid;
INPUT VALUES:

Enter the num coefficient [1];

Enter the den coefficient [1,-0.08];

OUTPUT WAVE FORM:

1.2

1.1
magnitude

0.9
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
normalised freq

0
phase in radus

-0.05

-0.1
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
normalised freq

PROGRAM:
%Frequency Response of II order%
clc;
clear all;
b=input('enter the num coff');
a=input('enter the den coff');
w=0:0.01:pi;
h=freqz(b,a,w);
subplot(2,1,1);
plot(w/pi,abs(h));
xlabel('normalised freq');
ylabel('magnitude');
grid;
subplot(2,1,2);
plot(w/pi,angle(h));
xlabel('normalised freq');
ylabel('phase in radus');
grid;
INPUT VALUES:

Enter the num coefficient [1,0,0.9];

Enter the den coefficient [1,0,0.4];

OUTPUT WAVE FORM:

1.5

1
magnitude

0.5

0
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
normalised freq

0.5
phase in radus

-0.5

-1
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
normalised freq

RESULT: Hence we generated the frequency response of a given System of I order and II
order.

VIVA QUESTIONS:

1. Which built in function is used to solve a given difference equation?


2. What is frequency response? Give equation for first order system and second
order system?
3. What is an LTI system?
4. What is steady state response?
5. Suppose we have a system with transfer function H(z) = 1 / ((z – 1.1)*(z
– 0.9)). Is the system stable or unstable?
EXPT NO 4: IMPLEMENTATION OF FFT OF A GIVEN SEQUENCE

AIM: To write a program to find FFT of given sequence

SOFTWARE USED: MATLAB7.0

THEORY: The Fast Fourier Transform is useful to map the time-domain sequence into a
continuous function of a frequency variable. The FFT of a sequence {x(n)} of length N is
given by a complex-valued sequence X(k).

M nk
 j2
X(k)   x(n) e n ;0  k  N 1
k0

The above equation is the mathematical representation of the DFT. As the number of
computations involved in transforming a N point time domain signal into corresponding
frequency domain signal was found to be N 2 complex multiplications, an alternative
algorithm involving lesser number of computations is opted. Dividing the DFT into smaller
DFTs is the basis of the FFT. A radix-2 FFT divides the DFT into two smaller DFTs, each of
which is divided into smaller DFTs and so on, resulting in a combination of two-point DFTs.
The Decimation -In-Time (DIT) FFT divides the input (time) sequence into two groups, one
of even samples and the other of odd samples. N/2 point DFT are performed on the these
sub-sequences and their outputs are combined to form the N point DFT.
PROGRAM:
% FFT of given sequence %
clc;
clear all;
x=input('enter input sequence a(n)');
n=length(x);
y=fft(x,n);
m=abs(y);
subplot(1,2,1);
stem(m);
xlabel('time');
ylabel('magnitude');
p=angle(y);
subplot(1,2,2);
stem(p);
xlabel('time');
ylabel('phase in radians');
title('phase plot');
INPUT:

Enter input sequence a(n) =[1 1 2 3];

OUTPUT WAVE FORM:

phase plot
7 4

6 3

5 2
phase in radians
4 1
magnitude

3 0

2 -1

1 -2

0 -3
1 2 3 4 1 2 3 4
time time

RESULT: Hence we generated FFT of a given sequence.

VIVA QUESTIONS:

1. FFT is in complex domain how to use it in real life signals optimally?


2. What is the difference between FFT and IFFT?
3. Explain using convolution the effects of taking an FFT of a sample with no windowing
4. What is the need of FFT?
5. What’s the difference between FFT and DFT?
6. Why do we need Fourier transform in DSP?
7. Give any practical application of FFT in daily life?
8. What is the importance of FFT in OFDMA technology?
EXP NO. 5: DETERMINATION OF POWER SPECTRUM OF A GIVEN
SIGNALS

AIM: To write a program to determine the power spectral density of given signal and
sequence.

SOFTWARE USED: MATLAB7.0

THEORY: The power spectral density (P.S.D) is a measurement of the energy at various
frequencies. In the previous section we saw how to unwrap the FFT and get back the sine
and cosine coefficients. Usually we only care how much information is contained at a
particular frequency and we don’t really care whether it is part of the sine or cosine series.
Therefore, we are interested in the absolute value of the FFT coefficients. The absolute
value will provide you with the total amount of information contained at a given
frequency, the square of the absolute value is considered the power of the signal.
Remember that the absolute value of the Fourier coefficients is the distance of the
complex number from the origin. To get the power in the signal at each frequency
(commonly called the power spectrum) you can try the following commands.
>> N = 8; %% number of points
>> t = [0:N-1]’/N; %% define time
>> f = sin(2*pi*t); %%define function
>> p = abs(fft(f))/(N/2); %% absolute value of the fft
>> p = p(1:N/2).^2 %% take the positve frequency half, only
This set of commands will return something much easier to understand, you should get 1
at a frequency of 1 and zeros everywhere else. Try substituting cos for sin in the above
commands, you should get the same result. Now try making >>f = sin(2*pi*t) +
cos(2*pi*t). This change should result in twice the power contained at a frequency of 1.

PROGRAM:
clc;
clear all;
f1=500;
f2=1000;
fs=2000;
t=0:1/fs:1;
x=2*sin(2*pi*f1*t)+3*sin(2*pi*f2*t)+rand(size(t));
psd1=abs(fft(x));
subplot(2,2,1);
plot(t*fs,10*log(psd1));
xlabel ('frequency');
ylabel ('magnitude');
title('power spectral density using square magnitude method');
psd2=abs(fft(xcorr(x),length(t)));
subplot(2,2,2);
plot(t*fs,10*log(psd2));
xlabel('frequency');
ylabel('magnitude');
title('power spectral density using auto corelation method');
S=[1,1,1,1,0,0,0,0];
N1=length(S);
N=32;
N2=64;
subplot(2,2,3);
psd_=abs(fft(S,N))/N1;
stem((0:(N-1))/N,psd_);
xlabel('discrete frequency f,f=K/N,K=0,1,2...N-1');
ylabel('power');
title('power spectrum ,FFT length N=32');
grid on;
subplot(2,2,4);
psd3=abs(fft(S,N2))/N1;
stem((0:(N2-1))/N2,psd3);
xlabel('discrete frequency f,f=K/N,K=0,1,2,....N-1');
ylabel('magnitude');
title('power spectrum,FFT length N=64');

OUTPUT WAVE FORM:

RESULT: Hence we generated the power spectral density of given signal and sequence.
VIVA QUESTIONS:

1. Define power spectral Density?

2. What is the need for spectral estimation?

3. Determine the power spectrum density?

4. What is the relation between auto correlation & spectral density


EXP NO. 6: IMPLEMENTATION OF LP FIR FILTER FOR A GIVEN
SEQUENCE/SIGNAL

AIM: To write a program for Implementation of LP FIR filter for a given sequences

SOFTWARE USED: MATLAB7.0

PROGRAM:

%LP FIR Filter %


clc;
clear all;
close all;
rp=input('enter the pass band ripple');
rs=input('enter the stop band ripple');
fp=input('enter the pass band frequency');
fs=input('enter the stop band frequency');
f=input('enter the sampling frequency');
wp=2*(fp/f);
ws=2*(fs/f);
num=-(20*log10(sqrt(rp*rs))-13);
dem=(14.6*(fs-fp)/f);
n=ceil(num/dem);
n1=n+1;
if (rem(n,2)~=0)
n1=n;
n=n-1;
end
y=boxcar(n1);
b=fir1(n,wp, 'low' ,y);
[h,o]=freqz(b,1,256);
m=20*log10(abs(h));
plot(o/pi,m);
ylabel('gain');
xlabel('normalized frequency');
title('rectangular low pass filter');
INPUT VALUES:

Enter the pass band ripple [0.05];

Enter the stop band ripple [0.04];

Enter the pass band frequency [1200];

Enter the stop band frequency [2400];

Enter the sampling frequency [9000];

OUTPUT WAVE FORM:


rectangular low pass filter
10

-10

-20
gain

-30

-40

-50

-60

-70
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
normalized frequency

RESULT: Hence we implemented the LP FIR filter for a given sequences/signal.


VIVA QUESTION:

1. What is filter?
2. What is FIR and IIR filter define, and distinguish between these two?
3. What is window method? How you will design an FIR filter using window
method?
4. What are low-pass and band-pass filter and what is the difference between these
two?
5. What is the matlab command for Hamming window? Explain.
6. What do you mean by built in function ‘abs’ and where it is used?
7. Explain how the FIR filter are stable?
8. Why is the impulse response "finite"?
9. What does "FIR" mean?
10.What are the advantages of FIR Filters (compared to IIR filters)?
11.What are the disadvantages of FIR Filters (compared to IIR filters)?
12.What terms are used in describing FIR filters?
13.What is the delay of a linear-phase FIR?
EXPT NO 7: IMPLEMENTATION OF HP IIR FILTER FOR A GIVEN
SEQUENCE/SIGNAL
AIM: To write a program for Implementation of HP IIR filter for a given sequences
a) Using Butterworth Filter
b) Using Chebyshev Filter

SOFTWARE USED: MATLAB7.0


THEORY: MATLAB contains various routines for design and analyzing digital
filter IIR. Most of these are part of the signal processing tool box. A selection of
these filters is listed below.

 Buttord ( for calculating the order of filter)

 Butter ( creates an IIR filter)

 Ellipord ( for calculating the order of filter) Ellip (creates an IIR filter)

 Cheb1ord (for calculating the order of filter) Cheyb1 (creates an IIR filter)

 Explanation Of The Commands For Filter Design: Buttord:

 Butterworth filter order selection.

[N, Wn] = BUTTORD(Wp, Ws, Rp, Rs) returns the order N of the lowest order digital
Butterworth filter that loses no more than Rp dB in the pass band and has at least Rs dB
of attenuation in the stop band. Wp and Ws are the pass band and stop band edge
frequencies, normalized from 0 to 1 (where 1 corresponds to pi radians/sample).
PROGRAM:
%Implementation of HP IIR filter for a given sequences Using Butterworth Filter%
clc;
clear all;
close all;
rp=input('enter the value of rp');
rs=input('enter the value of rs');
fp=input('enter the value of fp');
fs=input('enter the value of fs');
%%instalation of sapling freq%
fsp=10000;
%%normalised frequencie%%
wp=((2*fp)/fsp);
ws=((2*fs)/fsp);
%%order,cutoff freq.of the filter%%
[n,wn]=buttord(wp,ws,rp,rs,'s');
[b,a]=butter(n,wn,'high','s');
w=0:0.01:pi;
[h,om]=freqs(b,a,w);
m=(20*(log10(abs(h))));
%%for phase response%%
an=angle(h);
%%plotting the graphs%%
subplot(2,1,1);
plot(om/pi,m,'.r');
xlabel('normalized frequency');
ylabel('gain in db');
title('magnitude response in db');
%%plotting the graphs%%
subplot(2,1,2);
plot(om/pi,an,'--');
xlabel('frequency');
ylabel('phase in radians');
title('phase plot');

Input Values:

Enter the value of rp [0.5];

Enter the value of rs [50];

Enter the value of fp [1200];

Enter the value of fs [2400];


Output Waveform:
magnitude response in db
0

-100
gain in db

-200

-300
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
normalized frequency
phase plot
4
phase in radians

-2

-4
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
frequency

Result: Hence we implemented HP IIR filter for a given sequences using Butterworth
Filter
PROGRAM:
%Implementation of HP IIR filter for a given sequences Using Chebyshev Filter%

clc;
clear all;
close all;
rp=input('enter the value of rp');
rs=input('enter the value of rs');
fp=input('enter the valuek if fp');
fs=input('enter the value of fs');
%%instalation of sapling freq%
fsp=10000;
%%normalised frequencie%%
wp=((2*fp)/fsp);
ws=((2*fs)/fsp);
%%order,cutoff freq.of the filter%%
[n,wn]=cheb1ord(wp,ws,rp,rs,'s');
[b,a]=cheby1(n,rp,wp,'high','s');
w=0:0.01:pi;
[h,om]=freqs(b,a,w);
m=(20*(log10(abs(h))));
%%for phase response%%
an=angle(h);
%%plotting the graphs%%
subplot(2,1,1);
plot(om/pi,m,'.r');
xlabel('normalized frequency');
ylabel('gain in db');
title('magnitude response in db');
%%plotting the graphs%%
subplot(2,1,2);
plot(om/pi,an,'--');
xlabel('frequency');
ylabel('phase in radians');
title('phase plot');
Input Values:

Enter the value of rp [0.5];

Enter the value of rs [50];

Enter the value of fp [1200];

Enter the value of fs [2400];

Output Waveform:

magnitude plot
0

-100
magnitude

-200

-300
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
frequency
phase plot
4
phase in radians

-2

-4
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
frequency

Result: Hence we implemented HP IIR filter for a given sequences using Chebyshev
Filter.
VIVA QUESTION:
1. What do you mean by cut-off frequency?
2. Give the difference between analog and digital filter?
3. What is the difference between type 1 and type 2 filter structures?
4. What is the role of delay element in filter design?
5. Explain how the frequency is filter in filters?
6. Differences between Butterworth chebyshev filters?
7. Can IIR filters be linear phase? How to make it linear Phase?
EXPT NO 8.GENERATION OF SINUSOIDAL SIGNAL THROUGH
FILTERING

AIM: To generate a sinusoidal signal through filtering.

SOFTWARE: MATLAB 7.0

PROGRAM:
close all;
clear all;
clc;
b=[1];
a=[1,-1,0.9];
n=[-20:120];
t=0:0.1:2*pi;
x=sin(t);
s=filter(b,a,x);
stem(t,s);
title('sinusoidal response');
xlabel('n');
ylabel('s(n)');

OUTPUT WAVEFORM:

RESULT: Hence we generate the sinusoidal signal using filtering


EXPT NO 9: IMPLEMENTATION OF DECIMATION PROCESS

AIM: To write a program for Implementation of Decimation Process.

SOFTWARE USED: MATLAB7.0

THEORY: Decimation is the process of reducing the sampling frequency of a signal to a


lower sampling frequency that differs from the original frequency by an integer value.
Decimation also is known as down-sampling. The low pass filtering associated with
decimation removes high-frequency content from the signal to accommodate the new
sampling frequency. Decimation is useful in applications in which the Nyquist frequency
of a signal is much higher than the highest frequency of the signal. Decimation filters help
you remove the excess bandwidth and reduce the sampling frequency of the signal.
Decimation filters also help you reduce the computational resources required for
processing and storing the signal. During the analog-to-digital (A/D) conversion process,
decimation filters also can reduce the variance of quantization noise in a signal and
maintain the signal power, thus improving the signal-to-noise ratio (SNR).
The following figure shows a typical M-fold decimation filter, where M is the integer
value by which you want to decrease the sampling frequency. This filter contains a low
pass FIR filter H(z). This low pass FIR filter is an anti-aliasing filter followed by an M-
fold decimator. The decimator passes every Mth sample and discards the other samples.
After this operation, the decimation filter changes the sampling frequency fs of the input
signal x(n) to a new sampling frequency fs/M. The decimation filter then returns an output
signal y(n) with the new sampling frequency.
PROGRAM: % Implementation of Decimation Process%

clc;
clear all;
close all;
t=0:0.03:2;
x=cos(2*pi*t);
y=decimate(x,2);
t1=decimate(t,2);
%%Plotting Decimation Signals
% Plot for Input signal
subplot(2,1,1)
stem(t,x)
xlabel('Number of samples')
ylabel('Amplitude')
title('Input signal')
% Plot for Decimation
subplot(2,1,2)
stem(t1,y)
xlabel('Number of samples')
ylabel('Amplitude')
title('Decimated signal')
%disp('GRAPHS:')
Output Waveform:

Input signal
1

0.5
Amplitude

-0.5

-1
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
Number of samples
Decimated signal
1

0.5
Amplitude

-0.5

-1
-0.5 0 0.5 1 1.5 2
Number of samples

Result: Hence we implemented Decimation Process.


VIVA QUESTION:

1. What is the importance of decimation for a given signal/sequence?


2. What do you mean Aliasing? What is the condition to avoid aliasing for
sampling?
3. How does a poly phase filtering save computation in a decimation
filter?
4. Give any practical application of decimation?
5. Which signals can be down sampled?
6. What happens if I violate the Nyquist criteria in down sampling or
decimating?
7. What are "decimation" and "down sampling"?
8. What is the "decimation factor"?
EXPT NO 10: IMPLEMENTATION OF INTERPOLATION PROCESS

AIM: To write a program for Implementation of Interpolation Process

SOFTWARE USED: MATLAB7.0


PROGRAM: % Implementation of Interpolation Process%

clc;
clear all;
close all;
t=0:0.03:2;
x=cos(2*pi*t);
y1=interp(x,2);
t2=interp(t,2);
%Plotting Interpolation Signals
% Plot for Input signal
subplot(2,1,1)
stem(t,x)
xlabel('Number of samples')
ylabel('Amplitude')
title('Input signal')
% Plot for Interpolation
subplot(2,1,2)
stem(t2,y1)
xlabel('Number of samples')
ylabel('Amplitude')
title('Interpolated signal')
disp('GRAPHS:')
Output Waveform:

Input signal
1

0.5
Amplitude

-0.5

-1
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
Number of samples
Interpolated signal
2

1
Amplitude

-1

-2
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
Number of samples

Result: Hence we implemented Interpolation Process.


VIVA QUESTION:

1. How does polyphase filtering save computations in an interpolation filter?


2. Why do we need I&Q signals?
3. What is Interpolation and decimation filters and why we need it?
4. What are "up sampling" and "interpolation"?
5. Why interpolate needed for any signal/sequence?
6. What is the "interpolation factor"?
7. Which signals can be interpolated?
8. Can interpolate will happens in multiple stages? If yes give reason?
9. Give any example of a FIR interpolator?
EXPT.NO 11: IMPLEMENTATION OF I/D SAMPLING RATE
CONVERTERS

AIM: program to implement sampling rate conversion.

SOFTWARE: MATLAB 7.0

PROGRAM:
clc;% clear comand window
clear all; % clear work space
close all; %close all figure windows
%input signal
N=50 ;% no of samples
n=0:1:N-1;
x=sin(2*pi*n/15);% input signal
subplot(3,1,1)
stem(n,x);
xlabel('n');
ylabel('Amplitude');
title('Original Sequence');
%up sampling
L=2;% upsampling factor
x1=[zeros(1,L*N)];
n1=1:1:L*N;
j =1:L:L*N;
x1(j)=x;
subplot(3,1,2)
stem(n1-1,x1);
xlabel('n');
ylabel('Amplitude');
title('Upsampled Sequence');
% down sampling
M=2;
x2=x(1:M:N);
n2=1:1:N/M;
subplot(3,1,3)
stem(n2-1,x2);
xlabel('n');
ylabel('Amplitude');
title('Downsampled Sequence');

Output waveforms for Sampling Rate Conversion:

RESULT: Hence we implement the sampling rate conversion


EXPT NO 12: IMPULSE RESPONSE OF I & II ORDER SYSTEMS

AIM: To write a program to generate a Impulse response of I & II order Systems

SOFTWARE USED: MATLAB7.0


THEORY:-
LTI Discrete time system is completely specified by its impulse response i.e.
knowing the impulse response we can compute the output of the system to any arbitrary
input. Let h[n] denotes the impulse response of the LTI discrete time systems. Since
discrete time system is time invariant, its response to [n-1] will be h[n-1] .Likewise the
response to [n+2] , [n-4] and [n-6] will be h[n+2], h[n-4] and h[n-6] .

PROGRAM:

%Impulse Response Ist order%


clc;
clear all;
n=0:1:20;
x=[1,zeros(1,20)];
b=input('enter the num coefficient');
a=input('enter the den coefficient');
y=filter(b,a,x);
subplot(2,1,1);
stem(n,x);
xlabel('n');
ylabel('input sequence x(n)');
subplot(2,1,2);
stem(n,y);
xlabel('n');
ylabel('impulse response');
INPUT VALUES:

Enter the num coefficient for I order [1];

Enter the den coefficient for I order [1,-0.08];

OUTPUT WAVE FORM FOR I st ORDER IMPULSE RESPONSE:

1
input sequence x(n)

0.5

0
0 2 4 6 8 10 12 14 16 18 20
n

1
impulse response

0.5

0
0 2 4 6 8 10 12 14 16 18 20
n

PROGRAM :

%Impulse Response of II order%


clc;
clear all;
n=0:1:20;
x=[1,zeros(1,20)]
b=input('enter the num coefficient');
a=input('enter the den coefficient');
y=filter(b,a,x);
subplot(2,1,1);
stem(n,x);
xlabel('n');
ylabel('input sequence x(n)');
subplot(2,1,2);
stem(n,y);
xlabel('n');
ylabel('impulse response');

INPUT VALUES:

Enter the num coefficient for II order [1];

Enter the den coefficient for II order [1,-0.6,0.08];

OUTPUT WAVE FORM FOR II nd ORDER IMPULSE RESPONSE:

1
input sequence x(n)

0.5

0
0 2 4 6 8 10 12 14 16 18 20
n

1
impulse response

0.5

-0.5
0 2 4 6 8 10 12 14 16 18 20
n

RESULT: Hence we generated the impulse response of a I & II order Systems


EXPT NO 13: GENERRATION OF DTMF SIGNALS

AIM: To write a program for Generation of DTMF signals

SOFTWARE USED: MATLAB7.0

PROGRAM:

clc;
clear all;
%DTMF Generation%
d = input('enter the telephone digit= ','s');
symbol = abs(d);
tm = [49 50 51 65; 52 53 54 66; 55 56 57 67; 42 48 35 68];
for i = 1:4
for j = 1:4
if tm(i,j) == symbol,
break
end
end
if tm(i,j) == symbol,
break
end
end
f1 = [697 770 852 941];
f2 = [1209 1336 1477 1633];
fs = 8000;
dt = 1/fs;
t = 0:dt:1023/fs;
N = length(t);
x = sin(2*pi*f1(i)*t)+ sin(2*pi*f2(j)*t);
xf = 1/N*abs(fft(x,N));
f = fs*(0:round(N/2))/N;
f = f(1:round(N/2));
figure(1);
subplot(211)
plot(t,x)
subplot(212)
stem(f,xf(1:round(N/2)))
%DTMF Detection%
xfs = fliplr(sort(xf(1:round(N/2))));
fd = [];
for k = 1:N/2
if((xf(k) == xfs(1)) | (xf(k) == xfs(2)))
fd = [fd k];
end
end
fd =sort(fd);
dtmf1 = round(f(fd(1)));
dtmf2 = round(f(fd(2)));
for p = 1:4
if ((dtmf1 > f1(p)-5) & (dtmf1 < f1(p)+5))
dtmf1 = f1(p);
break
end
end
for q = 1:4
if ((dtmf2 > f2(q)-5) & (dtmf2 < f2(q)+5))
dtmf2 = f2(q);
break
end
end
disp('The tone frequencies are');
dtmf1
dtmf2
Output Waveform:
2

-1

-2
0 0.02 0.04 0.06 0.08 0.1 0.12 0.14

0.5

0.4

0.3

0.2

0.1

0
0 500 1000 1500 2000 2500 3000 3500 4000

Result: Hence we generated DTMF signals

You might also like