0% found this document useful (0 votes)
71 views56 pages

DSP Lab File

The document provides an overview of experiments to be conducted in a Digital Signal Processing lab over two cycles. Cycle I includes experiments on generating sinusoidal waveforms, performing DFT/IDFT, determining frequency response, implementing FFT, determining power spectra, and implementing various filters. Cycle II focuses on interpolation, decimation, and sampling rate conversion. Additional experiments include determining power spectra, converting between media formats, and audio/noise processing applications. Design experiments involve plotting signals from a microphone and matching to spectrograms.

Uploaded by

Kishore Ajay
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
71 views56 pages

DSP Lab File

The document provides an overview of experiments to be conducted in a Digital Signal Processing lab over two cycles. Cycle I includes experiments on generating sinusoidal waveforms, performing DFT/IDFT, determining frequency response, implementing FFT, determining power spectra, and implementing various filters. Cycle II focuses on interpolation, decimation, and sampling rate conversion. Additional experiments include determining power spectra, converting between media formats, and audio/noise processing applications. Design experiments involve plotting signals from a microphone and matching to spectrograms.

Uploaded by

Kishore Ajay
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 56

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 filter for a given sequence.
7. Implementation of LP IIR filter for a given sequence.
8. Implementation of HP IIR filter for a given sequence.

Cycle II:
9. Implementation of HP IIR filter for a given sequence.
10. Implementation of Decimation Process.
11. Implementation of Interpolation Process.
12. Implementation of I/D sampling rate converters.

Additional experiments:
1. Determination of Power Spectrum of a given signal(s).
2. Converting CD DATA TO DVD DATA

Design Experiments
1. Audio application such as to plot a time and frequency display of microphone plus a cosine using DSP.
Read a .wav file and match with their respective spectrograms.

2. Noise removal: Add noise above 3 KHz and then remove interference suppression using 400 Hz tone.
Open Experiment
1. Impulse response of first order and second order systems.
2. Implementation of I/D sampling rate converters
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
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.

1 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

Error messages

If we enter an expression incorrectly, MATLAB will return an error message. For example, in the following, we left
out the multiplication sign, *, in the following expression

>> x = 10;

>> 5x

Making corrections
To make corrections, we can, of course retype the expressions. But if the expression is

Lengthy, we make more mistakes by typing a second time. A previously typed command can be recalled with
the up-arrow key When the command is displayed at the command prompt, it can be modified if needed and
executed.

Controlling the hierarchy of operations or precedence

Let’s consider the previous arithmetic operation, but now we will include example,

1 + 2×3 will become (1 + 2) ×3

>> (1+2)*3

ans =9

and, from previous example

>> 1+2*3
ans =7

By adding parentheses, these two expressions give di errant results: 9 and 7 The order in which MATLAB
performs arithmetic operations is exactly that taught in high school algebra courses Exponentiations are done
first, followed by multiplications and divisions, and finally by additions and subtractions. However, the
standard order of precedence of arithmetic operations can be changed by inserting parentheses. For example,
the result of 1 +2×3 is quite deferent than the similar expression with parentheses (1+2) ×3. The results are 7
and 9 respectively. Parentheses can always be used to overrule priority and their use is recommended in some
complex expressions to avoid ambiguity.

Therefore, to make the evaluation of expressions unambiguous, MATLAB has established a series of rules.
The order in which the arithmetic operations are evaluated is given in Table 1.2. MATLAB arithmetic
operators obey the same precedence rules as those in Hierarchy of arithmetic operations Precedence
Mathematical operations

First The contents of all parentheses are evaluated first, starting from the innermost parentheses and working
outward Second All exponentials are evaluated, working from left to right Third All multiplications and
divisions are evaluated, working

from left to right Fourth All additions and subtractions are evaluated, starting

from left to rightmost computer programs. For operators of equal precedence, evaluation is from left to right
Now, consider another example:

In MATLAB, it becomes

>> 1/(2+3^2)+4/5*6/7 ans

=0.7766.

or, if parentheses are missing,

>> 1/2+3^2+4/5*6/7 ans

=10.1857.
So here what we get: two different results. Therefore, we want to emphasize the importance of precedence
rule in order to avoid ambiguity.

Controlling the appearance of floating point number

MATLAB by default displays only 4 decimals in the result of the calculations, for example -163. 6667, as
shown in above examples. However, MATLAB does numerical calculations in double precision, which is 15
digits. The command format controls how the results of computations are displayed. Here are some examples
of the different formats together with the resulting outputs

>> Format short

>> x=-163.6667

If we want to see all 15 digits, we use the command format long


>> Format long

>> x= -1.636666666666667e+002

To return to the standard format, enter format short, or simply format there are several other formats. For more
details, see the MATLAB documentation, or type help format Note - Up to now, we have let MATLAB
repeat everything that we enter at the prompt (>>). Sometimes this is not quite useful, in particular when the
output is pages en length. To prevent MATLAB from echoing what we type, simply enter a semicolon (;) at
the end of the command. For example,

>> x=-163.6667;

and then ask about the value of x by typing,

>> x

x =-163.6667

Managing the workspace

The contents of the workspace persist between the executions of separate commands. There-fore, it is
possible for the results of one problem to have aneect on the next one. To avoid this possibility, it is a good
idea to issue a clear command at the start of each new independent calculation

>> Clear

The command clear or clear all removes all variables from the workspace. This

frees up system memory. In order to display a list of the variables currently in the memory type

>> Who

While, whose will give more details which include size, space allocation, and class of the variables

Keeping track of your work session

It is possible to keep track of everything done during a MATLAB session with the diary

command.

>> Diary
Or give a name to a created file

>> Diary Filename

Where Filename could be any arbitrary name you choose

The function diary is useful if you want to save a complete MATLAB session.

They Save all input and output as they appear in the MATLAB window. When you want to stop the
recording, enter diary off. If you want to start recording again, enter diary on. The file that is created is a
simple text file. It can be opened by an editor or a word processing program and edited to remove extraneous
material, or to add your comments. You can use the function type to view the
diary file or you can edit in a text editor or print. This command is useful, for example in the process of
preparing a homework or lab submission.

Entering multiple statements per line

It is possible to enter multiple statements per line. Use commas (,) or semicolons (;) to Enter

more than one statement at once. Commas (,) allow multiple statements per line Without

suppressing output

>> a=7; b=cos(a), c=cash (a) b =0.6570

c =548.3170

Miscellaneous commands

Here are few additional useful commands:

• To clear the Command Window, type clc

• To abort a MATLAB computation, type ctrl-c

• To continue a line, type . . .

Getting help

To view the online documentation, select MATLAB Help from Help menu or MATLAB Help directly in the
Command Window. The preferred method is to use the Help Browser. The Help Browser can be started by
selecting the? Icon from the desktop toolbar. On the other hand, information about any command is available
by typing

>> help Command

Another way to get help is to use the look for command. The look for commandeers

from the help command. The help command searches for an exact function name match, while the look for
command searches the quick summary information in each function for a match. For example, suppose that
we were looking for a function to take

The inverse of a matrix. Since MATLAB does not have a function named inverse, the command help inverse
will produce nothing. On the other hand, the command look for inverse will produce detailed information,
which includes the function of interest, inv
>> look for inverse

Note - At this particular time of our study, it is important to emphasize one main point.

Because MATLAB is a huge program; it is impossible to cover all the details

of each function one by one. However, we will give you information how to get help. Here are some examples
• Use on-line help to request info on a specific function

>> help sqrt

• In the current version (MATLAB version 7), the doc function opens the on-line version of the help manual.
This is very helpful for more complex commands

>> Doc plot

• Use look for to find functions by keywords. The general form is

>>look for Function Name

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.


Dev Bhoomi Institute Of Technology LABORATORY
Department of Electronics and Communication MANUAL
Engineering
PRACTICAL INSTRUCTION SHEET
EXPERIMENT NO. 1 ISSUE NO. : ISSUE DATE:JULY 2011
REV. NO. : REV. DATE : PAGE: 2
LABORATORY Name & Code: Digital Signal Processing Lab SEMESTER: V

1. GENERATION OF BASIC SIGNALS USING MATLAB


AIM : To generate basic signals like unit impulse, unit step, unit ramp signal and Exponential signals.

Objective: To generate basic signals like unit impulse, unit step, unit ramp signal and Exponential signals
using MATlab.

Requirements : Computer with MATLAB software

(a). Program for the generation of UNIT impulse signal

clc; close all; clear all; t=-2:1:2;

y=[zeros(1,2),ones(1,1),zeros(1,2)] figure(1)

subplot(2,2,1); stem(t,y);

title('unit impulse');

(b). Program for the generation of UNIT step signal

clc; close all; clear all; n=input('enter

the n value'); t=0:1:n-1;

y=ones(1,n); figure(2)

subplot(2,2,2);

stem(t,y); title('unit

step');
(c).Program for the generation of unit RAMP signal

clc; close all; clear all; n=input('enter

the n value'); t=0:n;

y=ones(1,n); figure(3)

subplot(2,2,3);

stem(t,t); title('unit ramp');

(d).Program for the generation of Exponential signal

clc; close all; clear all;

n=input('the length of i/p sequency'); t=0:n

a=input('enter the a value');

y=exp(a*t); figure(4)

subplot(2,2,4);

stem(t,y);

xlabel('x-axis'); ylabel('y-axis'); title('unit exponential');


Dev Bhoomi Institute Of Technology LABORATORY
Department of Electronics and Communication MANUAL
Engineering
PRACTICAL INSTRUCTION SHEET
EXPERIMENT NO. 2 ISSUE NO. : ISSUE DATE
REV. NO. : REV. DATE : PAGE: 2
LABORATORY Name & Code: Digital Signal Processing Lab SEMESTER: V

2. AIM : To Generate continuous time sinusoidal signal, Discrete time cosine signal.
Requirements : Computer with MATLAB software

% Program for Continuous time signal clc;

close all; clear all;

t=0:.01:pi;

y= sin(2*pi*t);

subplot(4,1,1);

plot(t,y); ylabel('amp...');xlabel('(a)n...');title('sin signal')

%Program for Discrete time cosine signal :

t=0:.03:pi/3;

y= cos(2*pi*t);

subplot(4,1,2);

stem(t,y); xlabel('a(n)');ylabel('amplitude');title('cosinusoidal');

Results: Continuous time sinusoidal signal, discrete time cosine signal and sum of sinusoidal signal is
designed.
Outcomes: After finishing this experiment the students are able to

1. Generate elementary signals/ waveforms.


2. Perform arithmetic operations on signals.

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


Dev Bhoomi Institute Of Technology LABORATORY
Department of Electronics and Communication MANUAL
Engineering
PRACTICAL INSTRUCTION SHEET
EXPERIMENT NO. 3 ISSUE NO. : ISSUE DATE:
REV. NO. : REV. DATE : PAGE: 2
LABORATORY Name & Code: Digital Signal Processing SEMESTER: V

FREQUENCY RESPONSE:
3. To find frequency response of a given system given in (Transfer Function/
Differential equation form).

AIM:- To write a MATLAB program to evaluate the Frequency response of the system .

Objective: To write a MATLAB program to evaluate the Frequency response of the system
.

EQUIPMENTS:

Operating System - Windows XP Constructor - Simulator


Software - CCStudio 3 & MATLAB 7.5

THEORY:-

The Difference equation is given as


y[n]-0.25y[n-1]+0.45y[n-2]=1.55x[n]+1.95x[n-1]+ 2.15x[n]

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:

clc; clear all; close

all;

% Difference equation of a second order system

% y[n]-0.25y[n-1]+0.45y[n-2]=1.55x[n]+1.95x[n-1]+ 2.15x[n-2]

b=input('enter the coefficients of x(n),x(n-1)-----');


a=input('enter the coefficients of y(n),y(n-1)----'); N=input('enter the

number of samples of frequency response '); [h,t]=freqz(b,a,N);

subplot(2,1,1);
% figure(1); plot(t,h);
subplot(2,1,2);
% figure(2); stem(t,h);
title('plot of frequency response'); ylabel('amplitude');
xlabel('time index----->N'); disp(h);
grid on;
OUTPUT:
enter the coefficients of x(n),x(n-1)-----[1.55 1.95 2.15]
enter the coefficients of y(n),y(n-1)----[1 -.25 .45]
enter the number of samples of frequency response 1500

RESULT: The frequency response of given Differential equation is obtained. Hence the theory and
practical value are proved.

Objective: After finishing this experiment the students are able to


calculate and plot a frequency response of given Differential equation is obtained. Hence the theory
and practical value are proved.
Dev Bhoomi Institute Of Technology LABORATORY
Department of Electronics and Communication MANUAL
Engineering
PRACTICAL INSTRUCTION SHEET
EXPERIMENT NO. 4 ISSUE NO. : ISSUE DATE:
REV. NO. : REV. DATE : PAGE: 3
LABORATORY Name & Code: Digital Signal Processing Lab SEMESTER: V

AIM:- To write a MATLAB program to evaluate the impulse response of the system .

OBJECTIVE:- To write a MATLAB program to evaluate the impulse response of the system using
MATlab.

EQUIPMENTS:
Operating System - Windows XP Constructor - Simulator
Software - CCStudio 3 & MATLAB 7.5
The Difference equation is given as
y(n) = x(n)+0.5x(n-1)+0.85x(n-2)+y(n-1)+y(n-2)

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] .

From the above result arbitrary input sequence x[n] can be expressed as a weighted linear combination of
delayed and advanced unit sample in the form k=+

X[n] = x[k][n-k] k=-

where weight x[k] on the right hand side denotes specifically the k th sample value of the sequence.
The response of the LTI discrete time system to the sequence x[k] [n-k]

will be x[k] h [n-k].

As a result, the response y[n] of the discrete time system to x[n] will be given by k=+

y[n] = x[k] h [n-k] …………..(1) k=-

Which can be alternately written as k=+

y[n] = x[n-k] h [k]…………(2) k=-

The above equation (1) and (2) is called the convolution sum of the sequences x[n]

and h[n] and represented compactly as y[n]=x[n] * h[n] Where the notation * denotes the convolution sum.

Structure for Realization of Linear Time Invariant systems:


Let us consider the first order system Y(n)=-a 1y(n-1)+b0 x(n) +b1 x(n-1)

This realization uses separate delays(memory) for both the input and output samples and it is called as
Direct form one structure.

A close approximation reveals that the two delay elements contain the same input
w(n) and hence the same output w(n-1).consequently these two elements can be merged into

one delay. In contrast to the direct form I structure , this new realization requires only one

delay for auxiliary quantity w(n) ,and it is more efficient in terms of memory requirements. It

is called the direct form II structure and it is used extensively.

PROGRAM:-

clc; clear all; close

all;

% Difference equation of a second order system

% y(n) = x(n)+0.5x(n-1)+0.85x(n-2)+y(n-1)+y(n-2)

b=input('enter the coefficients of x(n),x(n-1)-----');

a=input('enter the coefficients of y(n),y(n-1)----'); N=input('enter the

number of samples of imp response '); [h,t]=impz(b,a,N);

subplot(2,1,1);
% figure(1); plot(t,h);
title('plot of impulse response');
ylabel('amplitude'); xlabel('time index----
->N'); subplot(2,1,2);
% figure(2); stem(t,h);
title('plot of impulse response');
ylabel('amplitude'); xlabel('time index----
->N'); disp(h);
grid on;
Output

enter the coefficients of x(n),x(n-1)-----[1 0.5 0.85] enter the coefficients of y(n),y(n-1)-----[1 -1 -1] enter the
number of samples of imp respons 41.0000 1.5000

3.3500

4.8500

CALCULATIONS:-
y(n) = x(n)+0.5x(n-1)+0.85x(n-2)+y(n-1)+y(n-2)

y(n) - y(n-1) - y(n-2) = x(n) + 0.5x(n-1) + 0.85x(n-2) Taking Z transform on both sides,

Y(Z) - Z-1 Y(Z)- Z-2 Y(Z) = X(Z) + 0.5 Z-1 X(Z) + 0.85 Z-2 X(Z) Y(Z)[1 - Z-1 - Z-2] = X(Z)[1 + 0.5 Z-1 +
0.85 Z-2 ]

But, H(Z) = Y(Z)/X(Z)

= [1 + 0.5 Z-1 + 0.85 Z-2 ]/ [1 - Z-1 - Z-2] By dividing we get H(Z) = 1 + 1.5 Z-1 + 3.35 Z-2 + 4.85 Z-3
h(n) = [1 1.5 3.35 4.85]

RESULT: The impulse response of given Differential equation is obtained. Hence the theory and practical
value are proved

Outcome: The students are able to write the MATlab code to find the impulse response of given Differential
equation is obtained and the theory and practical value are proved
Dev Bhoomi Institute Of Technology LABORATORY
Department of Electronics and Communication MANUAL
Engineering
PRACTICAL INSTRUCTION SHEET
EXPERIMENT NO. 6 ISSUE NO. : ISSUE DATE:JULY 2010
REV. NO. : REV. DATE : PAGE: 6
LABORATORY Name & Code: Digital Signal Processing SEMESTER: III

2. TO FIND DFT / IDFT OF GIVEN DT SIGNAL


AIM: To find the DFT / IDFT of given signal.

Objective: To wite the MATlab code to find the DFT / IDFT of given signal.

MATLAB Code:

w = [0:500]*pi/500;

z = exp(-j*w);

x = 3*(1-0.9*z).^(-1);

a = abs(x);

b = angle(x)*180/pi;

subplot(2,1,1);

plot(w/pi,a);

subplot(2,1,2);

plot(w/pi,b);
EQUIPMENTS:
Operating System - Windows XP
Constructor - Simulator
Software - CCStudio 3 & MATLAB 7.5

THEORY:
Discrete Time Fourier Transform:

The discrete-time Fourier transform (DTFT) X(ejω) of a sequence x[n] is defined

In general X(ejω) is a complex function of the real variable ω and can be written as

where Xre(ejω) and Xim(ejω) are, respectively, the real and imaginary parts of X(ejω), and are real functions of ω.
X(ejω) can alternately be expressed in the form

The quantity |X(ejω)| is called the magnitude function and the quantity θ(ω) is called the phase function

In many applications, the Fourier transform is called the Fourier spectrum and, likewise, |X(ejω)| and θ(ω)
are referred to as the magnitude spectrum and phase spectrum, respectively.

The DTFT X(ejω) is a periodic continuous function in ω with a period 2π. The DTFT satisfies a
number of useful properties that are often uitilized in a number of applications.

MATLAB COMMANDS:

For complex Z, the magnitude R and phase angle theta are given by:

R = abs (Z) Theta =

angle (Z)

Y = fft(X) returns the discrete Fourier transform of vector X, computed with a fast Fourier transform
(FFT) algorithm.

Y = fft(X)

Y = fft(X,n) returns the n-point FFT.


Y = fft(X, n)

Compute the discrete Fourier transform of the following function analytically and Then plot the
magnitude and phase:

Its DTFT is given as:

Evaluate the DTFT of the given coefficients.

num=[2 1]

den=[1 –0.6]

 Plot real and imaginary parts of Fourier spectrum.


 Also plot the magnitude and phase spectrum.

MATLAB CODE:

% Evaluation of the DTFT clc;


% Compute the frequency samples of the DTFT w = -

4*pi:8*pi/511:4*pi;
num = [2 1];

den = [1 -0.6];
h = freqz(num, den, w);

% Plot the DTFT

subplot(2,2,1)

plot(w/pi,real(h)); grid on;

title('Real part of H(e^{j\omega})')


xlabel('\omega /\pi'); ylabel('Amplitude');

subplot(2,2,2)
plot(w/pi,imag(h)); grid on;

title('Imaginary part of H(e^{j\omega})')


xlabel('\omega /\pi'); ylabel('Amplitude');

subplot(2,2,3)

Evaluate the DTFT of the given coefficients.

num=[2 1]

den=[1 –0.6]

 Plot real and imaginary parts of Fourier spectrum.


 Also plot the magnitude and phase spectrum.

MATLAB CODE:

% Evaluation of the DTFT clc;

% Compute the frequency samples of the DTFT w = -


4*pi:8*pi/511:4*pi;
num = [2 1];
den = [1 -0.6];

h = freqz(num, den, w);


% Plot the DTFT

subplot(2,2,1)

plot(w/pi,real(h)); grid on;

title('Real part of H(e^{j\omega})')

xlabel('\omega /\pi'); ylabel('Amplitude');

subplot(2,2,2)

plot(w/pi,imag(h)); grid on;

title('Imaginary part of H(e^{j\omega})')

xlabel('\omega /\pi'); ylabel('Amplitude');

subplot(2,2,3)
plot(w/pi,abs(h)); grid on;

title('Magnitude Spectrum |H(e^{j\omega})|')


xlabel('\omega /\pi');

ylabel('Amplitude');
subplot(2,2,4)
plot(w/pi,angle(h));

grid on;

title('Phase Spectrum

arg[H(e^{j\omega})]')

xlabel('\omega /\pi');

ylabel('Phase, radians');
PROGRAM:
Computation of N point DFT of a given sequence and to plot magnitude and phase spectrum.

N = input('Enter the the value of N(Value of N in N-Point DFT)'); x =


input('Enter the sequence for which DFT is to be calculated'); n=[0:1:N-1];
k=[0:1:N-1];
WN=exp(-1j*2*pi/N); % twiddle factor nk=n'*k;
WNnk=WN.^nk;
Xk=x*WNnk;
MagX=abs(Xk) % Magnitude of calculated DFT PhaseX=angle(Xk)*180/pi %
Phase of the calculated DFT figure(1); subplot(2,1,1);
plot(k,MagX);
subplot(2,1,2);
plot(k,PhaseX);

-------------*******-------------- OUTPUT
Enter the the value of N(Value of N in N-Point DFT)4 Enter the sequence for which DFT is to be
calculated [1 2 3 4]

MagX = 10.00002.8284 2.0000 2.8284

PhaseX = 0 135.0000 -180.0000 -135.0000

DFT of the given sequence is


10.0000-2.0000 + 2.0000i -2.0000 - 0.0000i -2.0000 -
2.0000i
Output:
RESULT: The DFT of given sequence is obtained . Hence the theory and practical value are proved.

Outcomes:

After finishing this experiment the students are able to :

1. Calculate DFT /IDFT of any given signal.


2. Plot 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. Differentiate between time variant and time invariant system. If x 1(n)={1,2,3,4} and x
2(n)={1,2,3} Find the convolution using tabular representation.
9. Draw all elementary standard discrete time signals.
10. Differentiate between causal and Non causal system.
11. If x 1(n)={1,2,3,4} and x 2(n)={5,6,7,8} Find the circular representation for the above sequences.
12. How can you compute Fourier transform form Z-transform ?
Dev Bhoomi Institute Of Technology LABORATORY
Department of Electronics and Communication MANUAL
Engineering
PRACTICAL INSTRUCTION SHEET
EXPERIMENT NO. 7 ISSUE NO. : ISSUE DATE:
REV. NO. : REV. DATE : PAGE: 8
LABORATORY Name & Code: Digital Signal Processing SEMESTER: V

AIM: To implementation of Fast Fourier Transform.

EQUIPMENTS:
Operating System - Windows XP
Constructor - Simulator
Software - CCStudio 3 & MATLAB 7.5

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
j
X(k) x(n) e n k N
k

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 its corresponding frequency domain signal was found
to be N2 complex multiplications, an alternative algorithm involving lesser number of computations is opted.

When the sequence x(n) is divided into 2 sequences and the DFT performed separately, the resulting
number of computations would be N2/2 i.e.

Consider x(2n) be the even sample sequences and x(2n+1) be the odd sample sequence derived form
x(n).

N/

would result in
(12)

The time burden created by this large number of computations limits the usefulness of DFT in many
applications. Tremendous efforts devoted to develop more efficient ways of computing DFT resulted in the
above explained Fast Fourier Transform algorithm. This mathematical shortcut reduces the number of
calculations the DFT requires drastically. The above mentioned radix-2 decimation in time FFT is employed
for domain transformation.

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.
The above shown mathematical representation forms the basis of N point FFT and is called the
Butterfly Structure.

STAGE - II

STAGE – I
STAGE - III FIG. 3A.2 - 8 POINT DIT

Fast Fourier Transform:

The Fast Fourier Transform (FFT) is just a computationally fast way to calculate the DFT.

Question No 03: USING INBUILT FUNCTION

Determine the Fourier transform of the following sequence. Use the FFT (Fast Fourier

Transform) function.

x (n) = {4 6 2 1 7 4 8}
MATLAB Code: for defined sequence n = 0:6;

x = [4 6 2 1 7 4 8];

a = fft(x);
mag = abs(a); pha =

angle(a); subplot(2,1,1);

plot(mag); grid on

title('Magnitude Response');

subplot(2,1,2);

plot(pha); grid on

title('phase Response');

IMPLEMENTATION OF FFT OF GIVEN SEQUENCE IN MATLAB

N-P OINT FFT WITHOUT USING INBUILT FUNCTION

PROGRAM:

clear all; close all;


clc;
x=input('Enter the sequence x[n]= ');
N=input('Enter the value N point= ');
L=length(x);
x_n=[x,zeros(1,N-L)]; for i=1:N
for j=1:N
temp=-2*pi*(i-1)*(j-1)/N; DFT_mat(i,j)=exp(complex(0,temp));
end end
X_k=DFT_mat*x_n';
disp('N point DFT is X[k] = '); disp(X_k);

mag=abs(X_k);
phase=angle(X_k)*180/pi;
subplot(2,1,1);
stem(mag); xlabel('frequency index
k');
ylabel('Magnitude of X[k]'); axis([0 N+1
-2 max(mag)+2]); subplot(2,1,2);
stem(phase); xlabel('frequency index
k'); ylabel('Phase of X[k]'); axis([0
N+1 -180 180]);

PROGRAM: for user defined sequence


%fast fourier transform clc;
clear all; close all;
tic;
x=input('enter the sequence');
n=input('enter the length of fft'); %compute fft disp('fourier
transformed signal');
X=fft(x,n)
subplot(1,2,1);stem(x); title('i/p signal'); xlabel('n -
-->');
ylabel('x(n) -->');grid;
subplot(1,2,2);stem(X);
title('fft of i/p x(n) is:');
xlabel('Real axis --->'); ylabel('Imaginary
axis -->');grid; OUTPUT:-
enter the sequence[1 .25 .3 4] enter the
length of fft4 fourier transformed
signal

X=

5.5500 0.7000 + 3.7500i -2.9500 0.7000 - 3.7500i GRAPH


FOR OUTPUT:-
RESULT: The Fast Fourier Transform of given sequence is obtained. Hence the theory and
practical value are proved.

Outcomes: After finishing this experiment the students are able


to:
VIVA 1. Able to Implement FFT of given sequence
QUESTIONS:
2. Identify the reduction of computations using FFT.
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?
9. In STB DVB how many point fft is currently using?
10. Give FFT & IFFT formulae and calculate for any sequence?
11. What is "decimation-in-time" versus "decimation-in-frequency"?
12. What is "bit reversal"?
13. How does the FFT work?
Dev Bhoomi Institute Of Technology LABORATORY
Department of Electronics and Communication MANUAL
Engineering
PRACTICAL INSTRUCTION SHEET
EXPERIMENT NO. 7 ISSUE NO. : ISSUE DATE:
REV. NO. : REV. DATE : PAGE: 3
LABORATORY Name & Code: Digital Signal Processing SEMESTER: V
Power Spectral Density
AIM: To verify Power Spectral Density

EQUIPMENTS:

Operating System - Windows XP


Constructor - Simulator
Software - CCStudio 3 & MATLAB 7.5

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 are 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.

Thus far we have looked at data that is defined on the time interval of 1 second, therefore we could interpret
the location in the number list as the frequency. If the data is taken over an arbitrary time interval we need to
map the index into the Fourier series back to a frequency in Hertz. The following m-file script will create
something that might look like data that we would obtain from a sensor. We will
.

PROGRAM:

%Power spectral density t =


0:0.001:0.6;
x = sin(2*pi*50*t)+sin(2*pi*120*t); y = x +
2*randn(size(t)); subplot(2,1,1);
% figure(1);
plot(1000*t(1:50),y(1:50))
title('Signal Corrupted with Zero-Mean Random Noise')
xlabel('time (milliseconds)');
Y = fft(y,512);
%The power spectral density, a measurement of the energy at various frequencies, is:
Pyy = Y.* conj(Y) / 512;
f = 1000*(0:256)/512;
subplot(2,1,2);
% figure(2);
plot(f,Pyy(1:257))
title('Frequency content of y');
xlabel('frequency (Hz)');

OUTPUT:-
RESULT: The power spectral density of given sequence is obtained. Hence the theory and practical
value are proved.

Outcome: At the end of the experiment the students are able to find the power spectral density of given
sequence is obtained.

VIVA QUESTION:
1. What do you mean by phase spectrum and magnitude spectrum/ give comparison?
2. How do you reduce spectral leakage?
3. What do you mean by spectral resolution?
Dev Bhoomi Institute Of Technology LABORATORY
Department of Electronics and Communication MANUAL
Engineering
PRACTICAL INSTRUCTION SHEET
EXPERIMENT NO. 8 ISSUE NO. : ISSUE DATE:
REV. NO. : REV. DATE : PAGE: 8
LABORATORY Name & Code: Digital Signal Processing SEMESTER: V
EXPERIMENT # 6 & 7
AIM : Design of FIR filters of Low pass and high pass filter using Matlab commands

EQUIPMENTS:
Operating System - Windows XP
Constructor - Simulator
Software - CCStudio 3 & MATLAB 7.5

.
DESCRIPTION: Digital filters refers to the hard ware 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.

 Truly linear phase response

 Better frequency response

 Filtered and unfiltered data remains saved for further use.

There are two type of digital filters.

1. FIR (finite impulse response) filter

2. IIR (infinite impulse response) filter

Description Of The Commands Used In FIR Filter Design FIR1:

FIR filters design using the window method.

B = FIR1(N,Wn) designs an N'th order low

pass FIR digital filter and returns the filter coefficients in length N+1 vector B. The cut- off

frequency Wn must be between 0 < Wn < 1.0, with 1.0 corresponding to half the sample rate. The

filter B is real and has linear phase. The normalized gain of the filter at Wn is -6 dB.
B = FIR1(N,Wn,'high') designs an N'th order highpass filter.

You can also use B = FIR1(N,Wn,'low') to design a lowpass filter.

If Wn is a two-element vector, Wn = [W1 W2], FIR1 returns an order N bandpass filter with passband
W1 < W < W2.

B = FIR1(N,Wn,'stop') is a bandstop filter if Wn = [W1 W2]. You can also specify If Wn is a multi-element
vector, Wn = [W1 W2 W3 W4 W5 ... WN], FIR1 returns an order N multiband filter with bands 0 < W <
W1, W1 < W < W2, ..., WN < W < 1.

B = FIR1(N,Wn,'DC-1') makes the first band a passband. B =

FIR1(N,Wn,'DC-0') makes the first band a stopband.

By default FIR1 uses a Hamming window. Other available windows, including Boxcar, Hann, Bartlett,
Blackman, Kaiser and Chebwin can be specified with an optional trailing argument.

For example, B = FIR1(N,Wn,kaiser(N+1,4)) uses a Kaiser window with beta=4. B =

FIR1(N,Wn,'high', chebwin(N+1,R)) uses a Chebyshev window.

For filters with a gain other than zero at Fs/2, e.g., highpass and bandstop filters, N must be even.

Otherwise, N will be incremented by one. In this case the window length should be specified as

N+2.

By default, the filter is scaled so the center of the first pass band has magnitude exactly one after windowing. Use a
trailing 'noscale' argument to prevent this scaling, e.g.

B = FIR1(N,Wn,'noscale')

B = FIR1(N,Wn,'high','noscale') B =

FIR1(N,Wn,wind,'noscale').

You can also specify the scaling explicitly, e.g. FIR1(N,Wn,'scale'), etc.
FREQZ Digital Filter Frequency Response.

[H,W] = FREQZ(B,A,N) returns the N-point complex frequency response vector H and the N-

point frequency vector W in radians/sample of the filter: given numerator and denominator

coefficients in vectors B and A. The frequency response is evaluated at N points equally spaced

around the upper half of the unit circle. If N isn't specified, it defaults to 512.

[H,W] = FREQZ(B,A,N,'whole') uses N points around the whole unit circle.

H = FREQZ(B,A,W) returns the frequency response at frequencies designated in vector W, in radians/sample


(normally between 0 and pi).

[H,F] = FREQZ(B,A,N,Fs) and [H,F] = FREQZ(B,A,N,'whole',Fs) return frequency vector F (in Hz),
where Fs is the sampling frequency (in Hz).

H = FREQZ(B,A,F,Fs) returns the complex frequency response at the frequencies designated in vector F
(in Hz), where Fs is the sampling frequency (in Hz).

[H,W,S] = FREQZ(...) or [H,F,S] = FREQZ(...) returns plotting information to be used with FREQZPLOT. S
is a structure whose fields can be altered to obtain different frequency response plots. For more information
see the help for FREQZPLOT.

FREQZ(B,A,...) with no output arguments plots the magnitude and unwrapped phase of the filter in the
current figure window

DESIGNING A LOW PASS FILTER:


Suppose the target is to pass all frequencies below 1200 Hz

fs=8000; % sampling frequency n=50; %


order of the filter w=1200/ (fs/2);
b=fir1(n,w,'low'); % Zeros of the filter
freqz(b,1,128,8000); % Magnitude and Phase Plot of the filter figure(2) [h,w]=freqz(b,1,128,8000);
subplot(2,1,1);
plot(w,abs(h));% Normalized Magnitude Plot
title('Normalized Magnitude Plot');
grid
subplot(2,1,2);
figure(2)
zplane(b,1); % the plot in lab
title('zplane');

DESIGNING HIGH PASS FILTER:


Now the target is to pass all frequencies above 1200 Hz

fs=8000; n=50;
w=1200/ (fs/2);
b=fir1(n,w,'high');
freqz(b,1,128,8000); % this function plots the phase(degree)and magnitude in db
subplot(2,1,2)
figure(2) [h,w]=freqz(b,1,128,8000);
plot(w,abs(h)); % Normalized Magnitude Plot
title('Magnitude Plot ');
grid
figure(3)
zplane(b,1); % this function plots fiq in zplane

Designing High Pass Filter: fs=8000;

n=50;

w=1200/ (fs/2);
b=fir1(n,w,'high');

freqz(b,1,128,8000); figure(2)

[h,w]=freqz(b,1,128,8000);

plot(w,abs(h)); % Normalized Magnitude Plot grid

figure(3) zplane(b,1);

Designing Band Pass Filter:


fs=8000; n=40;

b=fir1(n,[1200/4000 1800/4000],’bandpass’); freqz(b,1,128,8000) figure(2)

[h,w]=freqz(b,1,128,8000);

plot(w,abs(h)); % Normalized Magnitude Plot grid

figure(3) zplane(b,1);

Designing Notch Filter


fs=8000; n=40;

b=fir1(n,[1500/4000 1550/4000],'stop'); freqz(b,1,128,8000)

figure(2) [h,w]=freqz(b,1,128,8000);

plot(w,abs(h)); % Normalized Magnitude Plot grid

figure(3)
zplane(b,1);

Designing Multi Band Filter


n=50;

w=[0.2 0.4 0.6];

b=fir1(n,w); freqz(b,1,128,8000)

figure(2) [h,w]=freqz(b,1,128,8000);

plot(w,abs(h)); % Normalized Magnitude Plot grid

figure(3) zplane(b,1);

RESULT: The FIR low pass & high pass filter for given values is obtained. Hence the ideal and
practical response of FIR filter are proved.
Outcomes:
After finishing this experiment the students are able to:

1. Able to Implement LP FIR filter for a given sequence


2. Calculate the filter coefficients.

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?
14. What is the Z transform of a FIR filter?
15. What is the frequency response formula for a FIR filter?
16. How Can I calculate the frequency response of a FIR using the Discrete Fourier Transform (DFT)?
17. What is the DC gain of a FIR filter?
Dev Bhoomi Institute Of Technology LABORATORY
Department of Electronics and Communication MANUAL
Engineering
PRACTICAL INSTRUCTION SHEET
EXPERIMENT NO. 9 ISSUE NO. : ISSUE DATE:
REV. NO. : REV. DATE : PAGE: 8
LABORATORY Name & Code: Digital Signal Processing SEMESTER: V
EXPERIMENT # 8 & 9
IMPLEMENTATION OF ANALOG IIR LOW PASS AND HIGH PASS FILTER FOR A GIVEN
SEQUENCE

AIM: To implementation of IIR low pass and high pass filter.


To verify Frequency response of analog IIR filter using MATLAB (LP/HP).

EQUIPMENTS:
Operating System - Windows XP
Constructor - Simulator
Software - CCStudio 3 & MATLAB 7.5

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).

For example
Low pass: Wp = .1, Ws = .2 High pass:
Wp = .2, Ws = .1 Band pass: Wp = [.2 .7],
Ws = [.1 .8]
Band stop: Wp = [.1 .8], Ws = [.2 .7]

BUTTORD also returns Wn, the Butterworth natural frequency (or, the "3 dB frequency") to use with
BUTTER to achieve the specifications.
[N, Wn] = BUTTORD(Wp, Ws, Rp, Rs, 's') does the computation for an analog filter, in which case Wp and
Ws are in radians/second. When Rp is chosen as 3 dB, the Wn in BUTTER is equal to Wp in BUTTORD.

ELLIPORD: ELLIPTIC FILTER ORDER SELECTION.

[N, Wn] = ELLIPORD(Wp, Ws, Rp, Rs) returns the order N of the lowest order digital elliptic
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).

For example

Low pass: Wp = .1, Ws = .2 High pass:


Wp = .2, Ws = .1 Band pass: Wp = [.2 .7],
Ws = [.1 .8]
Band stop: Wp = [.1 .8], Ws = [.2 .7]

ELLIPORD also returns Wn, the elliptic natural frequency to use with ELLIP to achieve the
specifications.

[N, Wn] = ELLIPORD(Wp, Ws, Rp, Rs, 's') does the computation for an analog filter, in which case Wp
and Ws are in radians/second. NOTE: If Rs is much greater than Rp, or Wp and Ws are very close, the
estimated order can be infinite due to limitations of numerical precision.

CHEB1ORD:CHEBYSHEV TYPE I FILTER ORDER SELECTION.

[N, Wn] = CHEB1ORD(Wp, Ws, Rp, Rs) returns the order N of the lowest order digital
Chebyshev Type I 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).

For example,

Low pass: Wp = .1, Ws = .2 High pass:


Wp = .2, Ws = .1 Band pass: Wp = [.2 .7],
Ws = [.1 .8]
Band stop: Wp = [.1 .8], Ws = [.2 .7]

CHEB1ORD also returns Wn, the Chebyshev natural frequency to use with CHEBY1 to achieve the
specifications. [N, Wn] = CHEB1ORD(Wp, Ws, Rp, Rs, 's') does the computation for an analog filter, in
which case Wp and Ws are in radians/second.

BUTTER:BUTTERWORTH DIGITAL AND ANALOG FILTER DESIGN.

[B,A] = BUTTER(N,Wn) designs an Nth order lowpass digital Butterworth filter and returns the
filter coefficients in length N+1 vectors B (numerator) and A (denominator). The coefficients are
listed in descending powers of z. The cutoff frequency Wn must be
0.0 < Wn < 1.0, with 1.0 corresponding to half the sample rate.

If Wn is a two-element vector, Wn = [W1 W2], BUTTER returns an order 2N bandpass filter with passband
W1 < W < W2.
[B,A] = BUTTER(N,Wn,'high') designs a highpass filter.

[B,A] = BUTTER(N,Wn,'stop') is a bandstop filter if Wn = [W1 W2].

When used with three left-hand arguments, as in [Z,P,K] = BUTTER(...), the zeros and poles are
returned in length N column vectors Z and P, and the gain in scalar K. When used with four left-
hand arguments, as in [A,B,C,D] = BUTTER(...), state-space matrices are returned.

BUTTER(N,Wn,'s'), BUTTER(N,Wn,'high','s') and BUTTER(N,Wn,'stop','s') design analog


Butterworth filters. In this case, Wn is in [rad/s] and it can be greater than 1.0.

ELLIP: ELLIPTIC OR CAUER DIGITAL AND ANALOG FILTER DESIGN.

[B,A] = ELLIP(N,Rp,Rs,Wn) designs an Nth order low pass digital elliptic filter with Rp decibels
of peak-to-peak ripple and a minimum stop band attenuation of Rs decibels.
ELLIP returns the filter coefficients in length N+1 vectors B (numerator) and A (denominator).The cutoff
frequency Wn must be 0.0 < Wn < 1.0, with 1.0 corresponding to half the sample rate. Use Rp = 0.5 and Rs =
20 as starting points, if you are unsure about choosing them. If Wn is a two- element vector, Wn = [W1 W2],
ELLIP returns an order 2N band pass filter with pass band W1 < W < W2. [B,A] =
ELLIP(N,Rp,Rs,Wn,'high') designs a high pass filter.

[B,A] = ELLIP(N,Rp,Rs,Wn,'stop') is a band stop filter if Wn = [W1 W2].

When used with three left-hand arguments, as in [Z,P,K] = ELLIP(...), the zeros and poles are
returned in length N column vectors Z and P, and the gain in scalar K. When used with four left-
hand arguments, as in [A,B,C,D] = ELLIP(...), state-space matrices are returned.

ELLIP(N,Rp,Rs,Wn,'s'), ELLIP(N,Rp,Rs,Wn,'high','s') and ELLIP(N,Rp,Rs,Wn,'stop','s')


design analog elliptic filters. In this case, Wn is in [rad/s] and it can be greater than 1.0.

CHEBY1: CHEBYSHEV TYPE I DIGITAL AND ANALOG FILTER DESIGN.

[B,A] = CHEBY1(N,R,Wn) designs an Nth order lowpass digital Chebyshev filter with R decibels of peak-
to-peak ripple in the passband. CHEBY1 returns the filter coefficients in length N+1 vectors B (numerator)
and A (denominator). The cutoff frequency Wn must be 0.0 < Wn < 1.0, with 1.0 corresponding to half the
sample rate. Use R=0.5 as a starting point, if you are unsure about choosing R.
If Wn is a two-element vector, Wn = [W1 W2], CHEBY1 returns an order 2N bandpass filter with passband
W1 < W < W2.

[B,A] = CHEBY1(N,R,Wn,'high') designs a highpass filter.

[B,A] = CHEBY1(N,R,Wn,'stop') is a bandstop filter if Wn = [W1 W2].

When used with three left-hand arguments, as in [Z,P,K] = CHEBY1(...), the zeros and poles are returned
in length N column vectors Z and P, and the gain in scalar K.
When used with four left-hand arguments, as in [A,B,C,D] = CHEBY1(...), state-space matrices are returned.
CHEBY1(N,R,Wn,'s'), CHEBY1(N,R,Wn,'high','s') and CHEBY1(N,R,Wn,'stop','s')
design analog Chebyshev Type I filters.In this case, Wn is in [rad/s] and it can be greater than 1.0.

ALGORITHM:

1. Get the pass band and stop band ripples.


2. Get the pass band and stop band edge frequencies.
3. Get the sampling frequency.
4. Calculate the order of the filter.
5. Find the window coefficients.
6. Draw the magnitude and phase responses.

PROCEDURE:

1) Enter the pass band ripple (rp) and stop band ripple (rs).

2) Enter the pass band frequency (fp) and stop band frequency (fs).

3) Get the sampling frequency (f).

4) Calculate the analog pass band edge frequencies, w1 and w2. w1 =

2*fp/f w2 = 2*fs/f

5) Calculate the order and 3dB cutoff frequency of the analog filter. [Make use of the following function]
[n,wn]=buttord(w1,w2,rp,rs,’s’)

6) Design an nth order analog lowpass Butter worth filter using the following statement.
[b,a]=butter(n,wn,’s’)

7) Find the complex frequency response of the filter by using ‘freqs( )’ function
[h,om]=freqs(b,a,w) where, w = 0:.01:pi

This function returns complex frequency response vector ‘h’ and frequency vector ‘om’ in
radians/samples of the filter.

b(s) b(1)Snb-1+b(2)Snb-2+……………b(nb) H(s)=

a(s) a(1)Sna-1+a(2)Sna-2+…………..a(na)

Where a,b are the vectors containing the denominator and numerator coefficients.

8) Calculate the magnitude of the frequency response in decibels (dB) m=20*log10(abs(h))

9) Plot the magnitude response [magnitude in dB Vs normalized frequency (om/pi)] 10)Give

relevant names to x and y axes and give an appropriate title for the plot. 11)Repeat the

procedure for highpass, bandpass, bandstop filters.


12)Plot all the responses in a single figure window.[Make use of subplot( )].

9) Repeat the program for Chebyshev type-I and Chebyshev type-II filters.

PROGRAM CODE:

A. CHEBYSHEV LOW PASS FILTER


clc; clear all;

wp=0.5; %%% chebyshev low pass filter; ws=0.7;

rp=1; rs=50;

[n,wn]=cheb1ord(wp,ws,rp,rs);

[b,a]=cheby1(n,rp,wn);

[h,w]=freqz(b,a,128);

subplot(2,2,1) plot(abs(h));

xlabel('frequency');

ylabel('amplitude');

title('low pass chebyshev filter response');

B. BUTTER WORTH LOW PASS FILTER


wp=0.5; % butter worth low pass filter ws=0.7;

rp=1; rs=50;

[n,wn]=buttord(wp,ws,rp,rs); n

[b,a]=butter(n,wn);

[h,w]=freqz(b,a,128);

subplot(2,2,3)
plot(abs(h));

xlabel('frequency');6

ylabel('amplitude');

title('low pass butterworth filter response');

9.A CHEBYSHEV HIGH PASS FILTER


wp=0.7; %%% chebyshev high pass filter ws=0.5;

rp=1; rs=30;

[n,wn]=cheb1ord(wp,ws,rp,rs);

[b,a]=cheby1(n,rp,wn, 'high');

[h,w]=freqz(b,a,128);

subplot(2,2,2) plot(abs(h));

xlabel('frequency');

ylabel('amplitude');

title('high pass chebyshev filter response');

9.B BUTTER WORTH HIGH PASS FILTER


wp=0.7; %butter worth high pass filter ws=0.5;

rp=1; rs=30;

[n,wn]=buttord(wp,ws,rp,rs); n

[b,a]=butter(n,wn,'high');

[h,w]=freqz(b,a,128);
subplot(2,2,4) plot(abs(h));

xlabel('frequency');

ylabel('amplitude');

title('high pass butterworth filter response');

OUTPUT:

RESULT: The IIR low pass & high pass IIR filter for given values is obtained. Hence the ideal and
practical response of IIR filter are proved.
Outcomes:
After finishing this experiment the students are able to:
1. Implement HP FIR filter for a given sequence
2. Plot the response of the same.
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 structure?
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?
8. What is the special about minimum phase filter?
Dev Bhoomi Institute Of Technology LABORATORY
Department of Electronics and Communication MANUAL
Engineering
PRACTICAL INSTRUCTION SHEET
EXPERIMENT NO. 10 ISSUE NO. : ISSUE DATE:
REV. NO. : REV. DATE : PAGE: 2
LABORATORY Name & Code: Digital Signal Processing SEMESTER: V

Generation of Sinusoidal signal through filtering

AIM : To generate the sinusoidal signal using filter.

EQUIPMENTS:
Operating System - Windows XP
Constructor - Simulator
Software - CCStudio 3 & MATLAB 7.5

PROGRAME:
clear all close all
echo on
t0=.2; % signal duration ts=0.001; %
sampling interval fc=250; % carrier
frequency fs=1/ts; % sampling
frequency t=[-t0/2:ts:t0/2]; % time
vector kf=100; % deviation constant
m=cos(2*pi*10*t); % the message signal
int_m(1)=0;
for i=1:length(t)-1 % integral of m
int_m(i+1)=int_m(i)+m(i)*ts; echo off ;
end
echo on ;
u=cos(2*pi*fc*t+2*pi*kf*int_m); % modulated signal

%now lets filter the signal [z,p] =


butter(1,2*50/fs,'low');
filter_out = filter(50,[1 50],u); %this damn filter doesn't work!

subplot(2,1,1);
plot(t,u); hold on;
plot(t,m,'r');

subplot(2,1,2);
plot(t,filter_out); hold on;
plot(t,m,'r')

RESULT: The sinusoidal signal is generated from filter response for given values .

Outcome : At the end of the experiment the students are able to generate a sinusoidal signal is generated
from filter response for given values
VIVA QUESTION:
1. What is the special about minimum phase filter?
2. In signal processing, why we are much more interested in orthogonal transform?
3. How is the non-periodic nature of the input signal handled?
4. If a have two vectors how will i check the orthogonality of those vectors?
Dev Bhoomi Institute Of Technology LABORATORY
Department of Electronics and Communication MANUAL
Engineering
PRACTICAL INSTRUCTION SHEET
EXPERIMENT NO. 11 ISSUE NO. : ISSUE DATE:
REV. NO. : REV. DATE : PAGE: 3
LABORATORY Name & Code: Digital Signal Processing SEMESTER: V

IMPLEMENTATION OF DECIMATION PROCESS


AIM: To implementation of decimation of given sequence by factor M.

EQUIPMENTS:
Operating System - Windows XP
Constructor - Simulator
Software - CCStudio 3 & MATLAB 7.5

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
lowpass 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 lowpass FIR filter H(z). This lowpass FIR
filter is an anti-aliasing filter followed by anM-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.
equation for decimation

To prevent aliasing, this system uses the lowpass filter H(z) before the M-fold decimator to suppress the
frequency contents above the frequency fs/(2M), which is the Nyquist frequency of the output signal. This
system produces the same results as an analog anti-aliasing filter with a cutoff frequency of fs/(2M) followed
by an analog-to-digital (A/D) converter with a sampling frequency
of fs/M. Because the system shown in the figure above is in the digital domain, H(z) is a digital anti- aliasing
filter.

PROGRAM:

Clc; Close all;


Clear all;

N=input(‘ input length of the sine seq’); M=


input(‘ down sampling factor’);
fi= input(‘ input signal freq’); % generation of sine sequence t=0:N-1;
L=input(‘ enter the factor value’);
m=0:N*L-1;
x=sin(2*pi*fi*m);
%generate the down sample signal
Y=x([1:m:length(x)]);
Y([1:L:length(x)])=x;
Subplot(2,1,1);
Stem(n,x(1:N));
Title(‘ input sequence’);
Xlable(‘time’);
Ylabel(‘amplitude’);
Subplot(2,1,2);
Stem(n, Y);
Title([‘ output sequence ‘,num2str(m)]);

Xlable(‘time’);
Ylabel(‘amplitude’);

RESULT: The decimator for a given sequence is observed for chosen factor M. Hence the
theory and practical is verified.
Outcome : At the end of the experiment the student is able to perform decimator for a given sequence is
observed for chosen factor M.
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 poly phase filtering save computations 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. Can we do decimate in multiple stages?
8. What are "decimation" and "downsampling"?
9. What is the "decimation factor"?

The process of increasing the sampling rate is called interpolation. Interpolation is upsampling
followed by appropriate filtering. obtained by interpolating , is generally represented as:

The simplest method to interpolate by a factor of L is to add L-1 zeros in between the samples, multiply the
amplitude by L and filter the generated signal, with a so-called anti-imaging low pass filter at the high
sampling frequency

You might also like