Sei sulla pagina 1di 67

PALLAVI ENGINEERING COLLEGE

(Formerly Nagole Institute of Technology & Science)


Abdullapurmet(M), Near Hayathanagar.

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING

DIGITAL SIGNAL PROCESSING


LAB MANUAL
FOR

III BTECH ECE


2015-2016
INDEX

SL NAME OF THE DATE OF


NO DATE EXPERIMENT SUBMISSION SIGNATURE

2|DSP LAB Department of ECE


LIST OF EXPERIMENTS

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 Filter for a given Sequence/Signal.
9. Implementation 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.

3|DSP LAB Department of ECE


INTRODUCTION TO MATLAB
The name MATLAB stands for MATrix LABoratory. MATLAB was written originally to provide
easy access to matrix software developed by the LINPACK (linear system package) and EISPACK (Eigen
system package) projects.
MATLAB is a high-performance language for technical computing. It integrates computation,
visualization, and programming environment. Furthermore, MATLAB is a modern programming language
environment, it has sophisticated data structures, contains
built-in editing and debugging tools, and supports object-oriented programming. These factors make
MATLAB an excellent tool for teaching and research.
MATLAB has many advantages compared to conventional computer languages (e.g., C,
FORTRAN) for solving technical problems. MATLAB is an interactive system whose basic data element
is an array that does not require dimensioning. The software package has been commercially available
since 1984 and is now considered as a standard tool at most universities and industries worldwide.
It has powerful built-in routines that enable a very wide variety of computations. It also has easy to
use graphics commands that make the visualization of results immediately available. Specific applications
are collected in packages referred to as toolbox. There are toolboxes for signal processing, symbolic
computation, control theory, simulation, optimization, and several other fields of applied science and
engineering.
Matlab Window:
After logging into your account, you can enter MATLAB by double-clicking on the MATLAB
shortcut icon (MATLAB 2013b) 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

4|DSP LAB Department of ECE


Specialities of MATLAB:

 MATLAB is case-sensitive, which means that a + B is not the same as a + b.


 The MATLAB prompt (») in command window is where the commands are entered.

Matrices Representation:

1. row matrix:
Elements in a row are separated either by using white spaces or commas e.g.: a=[1 2 4 5]
2. column matrix:
Elements which differ by a column are separated by enter or semi column e.g.: b=[1; 2; 3]

Looking into particular element:


 a(row, column) allows to look the particular element in the matrix “a”
ex: a=[1 2 4,5 4 6,8 5 7]
b=a(5);
Here b value will be 4.
Vectors:
 d= [0:7]
”d” is a vector or row matrix with first element as 0 and last element as 7 and increment is by

5|DSP LAB Department of ECE


default 1.
Ans: d= [0 1 2 3 4 5 6 7]
 The default increment can be changed (to 0.1) by using increment field in between as
e= [0:0.1:1]
Ans: e=[0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0]
 g(1:2:9) look with increment 2
Ans: g=[1 3 5 7 9]
Operators:
1. + addition
2. - subtraction
3. * multiplication
4. ^ power
5. ' transpose
6. \ left division
7. / right division
 Remember that the multiplication, power and division operators can be used in conjunction with a
period to specify an element-wise operation.
Typical commands:
1. clc - to clear the command window.
2. close all - to close the previous program figures.
3. clear all - to clear the work space.
4. quit or exit - to close the MATLAB
5. save filename - filename.mat
6. load filename - retrive
7. dairy filename - b4 and after ascii text file
8. help - to search required query.
Built in Functions:
1. Scalar Functions:
 Certain MATLAB functions are essentially used on scalars, but to operate element-wise when
applied to a matrix (or vector). They are summarized below.
1. sin - trigonometric sine
2. cos - trigonometric cosine
3. tan - trigonometric tangent
4. asin - trigonometric inverse sine (arcsine)
5. acos - trigonometric inverse cosine (arccosine)
6. atan - trigonometric inverse tangent (arctangent)
7. exp - exponential

6|DSP LAB Department of ECE


8. log - natural logarithm
9. abs - absolute value
10. sqrt - square root
11. rem - remainder
12. round - round towards nearest integer
13. floor - round towards negative infinity
14. ceil - round towards positive infinity
2.Vector Functions:
Other MATLAB functions operate essentially on vectors returning a scalar value. Some of these
functions are given below.
1. max -largest component
2. min -smallest component
3. length -length of a vector
4. sort -sort in ascending order
5. sum -sum of elements
6. prod -product of elements
7. median -median value
8. mean -mean value std standard deviation
Few more commands:
Commands in the second sub-category of matrix functions are
1. size -size of a matrix
2. det -determinant of a square matrix
3. inv -inverse of a matrix
4. rank -rank of a matrix
5. rref -reduced row echelon form
6. eig -eigen values and eigenvectors
7. poly -characteristic polynomial
8. norm -norm of matrix (1-norm, 2-norm, ∞ -norm)
9. cond -condition number in the 2-norm
10. lu -LU factorization
11. qr -QR factorization
12. chol -Cholesky decomposition
13. svd -singular value decomposition

7|DSP LAB Department of ECE


Matrix Functions:
Much of MATLAB’s power comes from its matrix functions. These can be further separated into two
sub-categories. The first one consists of convenient matrix building functions, some of which are given
below.
1. eye - identity matrix
2. zeros - matrix of zeros
3. ones - matrix of ones
4. diag - extract diagonal of a matrix or create diagonal matrices
5. triu - upper triangular part of a matrix
6. tril - lower triangular part of a matrix
7. rand - randomly generated matrix

8|DSP LAB Department of ECE


EXPERIMENT 1
GENERATION OF SINUSOIDAL WAVEFORM / SIGNAL BASED ON RECURSIVE
DIFFERENCE EQUATIONS

AIM: Generate a Sinusoidal Signal based on recursive difference equation.

EQUIPMENTS NEEDED:
Host (PC) with windows (95/98/Me/XP/NT/2000), MATLAB software

ALGORITHM:

1. Enter the sampling frequency.

2. Enter the Signal frequency.

3. Calculate the coefficients of x(n) & y(n).

4. Find the Recursive differential equation.


5. Draw the Signal and its spectrum.

THEORY:
A Recursive filter has feedback from output to input, and in general its output is a function of the
previous output samples and the present and past input samples as described by the following equation

N M
y(m)=∑ak y(m − k)+∑bk x(m − k)
k =1 k =0

where {ak, bk} are the filter coefficients, and the output y(m) is a linear combination of the previous
N output samples [y(m−1),…, y(m−N)], the present input sample x(m) and the previous M input samples
[x (m−1),…, x( m−M)]. Thus a recursive filter is also known as an Infinite Impulse Response (IIR) filter.

A Non-Recursive filter has no feedback and its input-output relation is given by,

M
y(m)=∑bk x(m − k)
k =0

The output y(m) of a non-recursive filter is a function only of the input signal x(m). The response of such
a filter to an impulse consists of a finite sequence of M+1 samples, where M is the filter order. Hence, the
filter is known as a Finite Impulse Response (FIR) filter.
A first-order filter Recursive difference equation is given by,

y(m) =a y(m −1) + x(m)

9|DSP LAB Department of ECE


PROGRAM:

clc;
clear all;
close all;
% Signal Frequency and Sampling Frequency

% fs=input('enter the sampling frequency of the signal= ');

% f_hz=input('enter the signal frequency in Hz= ');

f_hz=1000; % Signal frequency (Change this value and test)

fs=8000; % Sampling frequency (change this value and test)

f0=2*pi*f_hz/fs; % Sampled Signal Frequency in Radians

% Calculation of y(n) coefficients

a1=2*cos(f0); a2=-1;

% Calculation of x(n) coefficients

b1=sin(f0);

%xnm1=zeros(1,128); % Initialize the input to be zero

% Initial values

xnm1=1; ynm1=0; ynm2=0;

% Initializing output to zero

% output=zeros(1,200);

y1=zeros(1,200);

for i=1:200

y1(i)=b1*xnm1+a1*ynm1+a2*ynm2; % Recursive Equation

ynm2=ynm1;

ynm1=y1(i);

%output(i)=y1(i);

end

% Plot of Signal and its Spectrum

subplot(2,1,1)

plot(1:length(y1),y1);

10 | D S P L A B Department of ECE
xlabel('Time in ms-----> ');

ylabel('Amplitude in volts-----> ');

title(['Sinusoidal Signal of frequency ', num2str(f_hz), ' Hz']);

Ak=2*abs(fft(y1))/length(y1); % Finding Spectrum using FFT

Ak(1)=Ak(1)/2; % One Sided spectrum

f=(0:1:(length(y1)-1)/2)*fs/length(y1); % Indices to frequency in Hz to plot

subplot(2,1,2)

plot(f,Ak(1:(length(y1)+1)/2));

xlabel('Frequency in Hz ')

ylabel('Magnitude in db ');

title(['Spectrum at ', num2str(f_hz), ' Hz frequency']);

11 | D S P L A B Department of ECE
OUTPUT:

Figure 1: A 1000Hz sine signal with its spectrum

RESULT:

A sinusoidal signal is generated using Recursive difference equation.

VIVA QUESTIONS:

1. Define Signal.
2. Define system.
3. What is Recursive Filter.
4. What is Non-Recursive Filter.
5. Which filter is called Recursive Filter.
6. Which filter is called Non-Recursive Filter.
7. Write the first order Recursive difference equation.
8. Write the second order Recursive difference equation coefficients.

12 | D S P L A B Department of ECE
EXPERIMENT 3
TO FIND DFT / IDFT OF GIVEN DT SIGNAL

AIM: To find the DFT and IDFT of a given sequence.

EQUIPMENTS REQUIRED:
Host (PC) with windows (95/98/Me/XP/NT/2000), matlab software.

ALGORITHM:

1. Enter the input Sequence.

2. Find the DFT of a given sequence.

3. Find the IDFT of a given sequence.

4. Plot of input signal and reconstructed signal.


5. Draw the Magnitude and Phase spectrum.

THEORY:
Definition: The sequence of N complex numbers x0, ...,xN-1 is transformed into the sequence of N complex
numbers X0, ..., XN-1 by the DFT according to the formula

Where k =0,…..,N-1

The Discrete Fourier Transform (DFT) converts a finite list of equally spaced samples of a function into
the list of coefficients of a finite combination of complex sinusoids, ordered by their frequencies, that has
those same sample values. The DFT spectrum is periodic with period N.

The Inverse DFT (IDFT) equation is given by

Where n= 0,….,N-1

The inverse DFT is the same as the DFT, but with the opposite sign in the exponent and a 1/N factor.

13 | D S P L A B Department of ECE
PROGRAM:

clc

clear all

close all

% Enter the input sequence

x=input('enter the input sequence: ');

N=length(x);

n=0:1:N-1;

k=0:1:N-1;

subplot(2,2,1);

stem(n,x)

xlabel('-----> n');

ylabel('-----> x(n)');

title('Input sequence');

% DFT of a given input sequence

wn=exp(-j*2*pi/N);

Nk=n'*k;

wn.Nk=wn.^Nk;

xk=x*wn.Nk;

subplot(2,2,2);

stem(k,xk)

xlabel('-----> k');

ylabel('-----> X(k)');

title('DFT sequence');

% Magnitude Spectrum of DFT sequence

y=abs(xk);

subplot(2,2,3);

stem(k,y)
14 | D S P L A B Department of ECE
xlabel('-----> k');

ylabel('-----> magnitude in db');

title('Magnitude Spectrum of DFT sequence');

% phase spectrum of DFT sequence

z=angle(xk);

subplot(2,2,4);

stem(k,z)

xlabel('-----> k');

ylabel('-----> phase in radians');

title('Phase Spectrum of DFT sequence');

OUTPUT:

Enter the input sequence: [1 2 3 4 5 6 7 8]

Figure: DFT of input sequence

15 | D S P L A B Department of ECE
% IDFT of a given DFT sequence

x=input('Enter the DFT sequence: ');

N=length(x);

n=0:1:N-1;

k=0:1:N-1;

subplot(2,2,1);

stem(k,x)

xlabel('-----> k');

ylabel('-----> X(k)');

title('DFT sequence');

% IDFT of sequence

wn=exp(j*2*pi/N);

Nk=n'*k;

wn.Nk=wn.^Nk;

xn=(x*wn.Nk)/N;

subplot(2,2,2);

stem(n,xn)

xlabel('-----> n');

ylabel('-----> x(n)');

title('IDFT sequence');

% Magnitude Spectrum of IDFT sequence

y=abs(xn);

subplot(2,2,3);

stem(n,y)

xlabel('-----> n');

ylabel('-----> magnitude in db');

title('Magnitude Spectrum of x(n)');

% phase spectrum of IDFT sequence

16 | D S P L A B Department of ECE
z=angle(xn);

subplot(2,2,4);

stem(n,z)

xlabel('-----> n');

ylabel('-----> phase in radians');

title('Phase Spectrum of x(n) ');

OUTPUT:

Enter the DFT sequence: [8 0 0 0 0 0 0 0]

Figure: IDFT of given DFT sequence

RESULT: The DFT and IDFT of a given sequence is obtained.

17 | D S P L A B Department of ECE
VIVA QUESTIONS:

1. Define DFT(Discrete Fourier Transform).


2. Define Inverse DFT.
3. What is the relation between DTFT and DFT.
4. Give any two applications of DFT .
5. State the properties of DFT.
6. When an N-point periodic sequence is said to be even or odd sequence?
7. What is zero padding? Why it is needed?
8. What is circular convolution?
9. How w ill you perform linear convolution via circular convolution?
10. What is overlap-add method?
11. What is overlap-save method?
12. What are differences between overlap-save and overlap-add methods.
13. What way zero padding is implemented in overlap save method?

18 | D S P L A B Department of ECE
EXPERIMENT 4

TO FIND FREQUENCY RESPONSE OF A GIVEN SYSTEM GIVEN IN (TRANSFER


FUNCTION/ DIFFERENTIAL EQUATION FORM)

AIM:

To find the frequency response of a given system given in (Transfer Function/ Differential equation
form).

EQUIPMENTS REQUIRED:
Host (PC) with windows (95/98/Me/XP/NT/2000), matlab software

ALGORITHM:

1. Define the numerator & denominator coeffiecients and normalized Frequency points.

2. Find the Frequency response.

3. Caluclate the Magnitude and Phase.


4. Draw the Magnitude and Phase spectrum.

THEORY:

Frequency response is the quantitative measure of the output spectrum of a system or device in response to
a stimulus, and is used to characterize the dynamics of the system. It is a measure of magnitude and phase
of the output as a function of frequency, in comparison to the input. In simplest terms, if a sine wave is
injected into a system at a given frequency, a linear system will respond at that same frequency with a
certain magnitude and a certain phase angle relative to the input. Also for a linear system, doubling the
amplitude of the input will double the amplitude of the output. In addition, if the system is time-invariant,
then the frequency response also will not vary with time.

An LTI system's frequency response provides a similar function: it allows you to calculate the effect that a
system will have on an input signal, except those effects are illustrated in the frequency domain.

The frequency response is given by


H(w) = Y (w)/X(w),
and can be found by taking Fourier transforms of the input-output relation.

19 | D S P L A B Department of ECE
PROGRAM:

clear all;

close all;

b=[1 2];

a=[1,-0.8];

w=0:0.01:2*pi;

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

subplot(2,1,1);

plot(w/pi,abs(h));

title('freq response of first order system');

xlabel('normalised freq');

ylabel('magnitude');

subplot(2,1,2);

plot(w/pi,angle(h));

xlabel('normalised freq');

ylabel('phase in radians');

figure(2)

zplane(b,a)

20 | D S P L A B Department of ECE
Output:

freq response of first order system


6
magnitude

0
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
normalised freq

1
phase in radians

0.5

-0.5

-1
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
normalised freq

Result:

The frequency response of a given system given in Transfer Function ( Differential equation form) is
obtained.

VIVA QUESTIONS:

1. Define Frequency response of the system.


2. Determine the magnitude and phase response of the given equation
y(n) =x(n)+x(n-2) .
3. Determine the frequency response for the system given by
y(n)-y3/4y(n-1)+1/8 y(n-2) = x(n)- x(n-1).
4. Determine the pole and zero plot for the system described difference equations
y(n)=x(n)+2x(n-1)-4x(n-2)+x(n-3).
5. Find the output of the system whose input- output is related by the difference equation
y(n) -5/6 y(n-1) +1/6 y(n-2) = x(n) -1/2 x(n-1) for the step input.
6. Find the output of the system whose input- output is related by the difference equation
y(n) -5/6 y(n-1) +1/6 y(n-2) = x(n) -1/2 x(n-1) for the x(n) =4 n u(n).

21 | D S P L A B Department of ECE
EXPERIMENT 6

IMPLEMENTATION OF FFT OF GIVEN SEQUENCE

AIM: To find the FFT of a given sequence.

EQUIPMENTS REQUIRED:
Host (PC) with windows (95/98/Me/XP/NT/2000), matlab software

ALGORITHM:

1. Enter the input Sequence.

2. Find the FFT of a given sequence.

3. Plot of input sequence and FFT of a sequence.


4. Draw the Magnitude and Phase spectrum.

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

N2 N2
21 21
x(k )   x(2n) WN2 nk   x(2n  1) WN( 2 n1) k
n 0 n 0

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

N2
21
 x ( 2 n)
n 0
WN2 nk

would result in

22 | D S P L A B Department of ECE
N2
21

(N/2)2 multiplication’s  x(2n  1)


n 0
WN( 2 n1) k

an other (N/2)2 multiplication's finally resulting in (N/2)2 + (N/2)2

N2 N2 N2
=   Computations
4 4 2

Further solving equation

N2 N
21 21 k
x ( k )   x ( 2n ) W 2 nk
N   x(2n  1) W ( 2 nk )
N W
N
n 0 n 0

N N
21 k 21
  x(2n) WN2 nk  W  x(2n  1) WN( 2 nk )
N
n 0 n 0

Dividing the sequence x(2n) into further 2 odd and even sequences would reduce the computations.

 j 2

WN = Twiddle factor e n

  j 2 
  nk
W nk
N e  n 

 N  N  j 2  j 2 n
 K   K  k
W 
N
2
 WN W 
N
2
e n
e n 2

 j 2
k
W k
N e n
 WNk (cos   j sin  )

 N  N
 K   K 
W 
N
2
 W (1)  W
k
N

N
2
 WNk
Employing this equation, we deduce

23 | D S P L A B Department of ECE
N2 N
21 21
x(k )   x(2n) WN2 nk   x(2n  1) WN( 2 nk )
n 0 n 0

N
21 K N
N
x(k  )   x(2n) WN  W  x(2n  1) 21 WN( 2 nk )
2 nk

2 n 0 N

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.

FIGURE: BUTTERFLY STRUCTUTE OF N-POINT FFT.

The above shown mathematical representation forms the basis of N point FFT and is called the Butterfly
Structure.

24 | D S P L A B Department of ECE
STAGE – I STAGE - II

STAGE – III

FIG. 8 POINT DIT

25 | D S P L A B Department of ECE
PROGRAM:

%% Clear Section

clear all;

close all;

clc;

Fs = 1000;

T = 1/ Fs;

t = 0:T:10;

%x=sin( 2 * pi * 15 * t ) + sin ( 2 * pi * 30 * t);

x = input( ‘ enter the signal : ‘ );

rxx = xcorr(x,x);

Sxx = fft(rxx,N);

Plot(f,abs(Sxx));

Xlabel(‘frequency’);

Ylabel(‘abs(Sxx)’);

Title(‘power spectral density ‘);

26 | D S P L A B Department of ECE
OUTPUT:

Figure: Magnitude & Phase plot of FFT sequence

RESULT:

FFT of a given sequence is obtained.

VIVA QUESTIONS:

1. What is FF T?
2. Why FF T is needed?
3. What is radix-2 FFT?
4. How many multiplications and additions are required to compute N point DF T using
radix-2 FFT?
5. What is DIT algorithm?
6. What DIF algorithm?
7. What are the applications of FF T algorithm?
8. Why the computations in FF T algorithm is said to be in place?
9. What are the differences and similarities between DIF and DIT algorithms?
10. What is phase factor or twiddle factor?
11. Draw and explain the basic butterfly diagram or flow graph of DIT radix-2 FF T.
12. What is DIT radix-2 FF T?
13. Draw and explain the basic butterfly diagram or flow graph of DIF radix-2 FFT.
14. Compare the DIT and DIF radix-2 FF T.

27 | D S P L A B Department of ECE
EXPERIMENT 7

DETERMINATION OF POWER SPECTRUM OF A GIVEN SIGNAL(S)

AIM: Find the Power spectrum density of a given signals.

EQUIPMENTS REQUIRED:
Host (PC) with windows (95/98/Me/XP/NT/2000), matlab software

ALGORITHM:

1. Compute the Auto Correlation of Sine wave .


2. Take output of auto correlation, apply FFT algorithm .
3. Use Graph option to view the PSD.
4. Repeat Step-1 to 3 for different type of signals .

THEORY:

Power Spectral Densfty (PSD) is the frequency response of a random or periodic signal. It tells us where
the average power is distributed as a function of frequency.

 The PSD is deterministic, and for certain types of random signals is independent of time1. This is
useful because the Fourier transform of a random time signal is itself random, and therefore of
little use calculating transfer relationships (i.e., finding the output of a filter when the input is
random).

 The PSD of a random time signal x(t) can be expressed in one of two ways that are equivalent to
each other

1. The PSD is the average of the Fourier transform magnitude squared, over a large time interval


1
2

 x(t)e
T
 j 2ft
S x ( f )  lim E  dt 
T  2T


T 

2. The PSD is the Fourier transform of the auto-correlation function.

 R ( )e
T
 j 2ft
Sx ( f )  x dt
T

28 | D S P L A B Department of ECE
Rx ( )  Ex(t ) x * (t   )

 The power can be calculated from a random signal over a given band of frequencies as follows:


1. Total Power in x(t): P
 S ( f )df  R (0)

x x

 S ( f )df  R (0)
f2
2. Power in x(t) in range f1 - f2: P12  x x
f1

1
The signal has to be stationary, which means that us statistics do not change as a function of time.

properties of psd and power spectrum:


1. The total area under the Power Spectrum or PSD is equal to the total avg. power of the signal.

2. The PSD is always positive.

3. The PSD is an even function of frequency or in other words, it is symmetrical.

4. The auto-correlation function and PSD are a Fourier transform pair. To compute PSD, we compute
the auto-correlation of the signal and then take its FFT.

5. The value of the auto-correlation function at zero-time equals the total power in the signal.
Keep in mind that total or the average power in a signal is often not of as great an interest. We are
most often interested in the PSD or the Power Spectrum. We often want to see is how the input
power has been redistributed by the channel and in this frequency-based redistribution of power is
where most of the interesting information lies

29 | D S P L A B Department of ECE
PROGRAM

clc;

clear all;

close all;

Fs=100;

N=512;

t=0:1/Fs:10;

f=Fs*(0:N-1)/N;

%x=sin(2*pi*15*t)+sin(2*pi*30*t);

x=input('Enter the signal :');

rxx= xcorr(x,x);

Sxx=fft(rxx,N);

plot(f,abs(Sxx));

xlabel('frequency f');

ylabel('abs(Sxx)');

title('Power Spectral Density');

30 | D S P L A B Department of ECE
Output:

Enter the signal : sin(2*pi*15*t)+sin(2*pi*30*t)

x 10
4
Power Spectral Density
3.5

2.5
abs(Sxx)

1.5

0.5

0
0 10 20 30 40 50 60 70 80 90 100
frequency f

Enter the signal: exp (-2t)

Result: The power spectrum of given signals are found

31 | D S P L A B Department of ECE
VIVA QUESTIONS:

1. Define Power Spectral Density of the Signal.


2. Derive the relation between psd and Auto correlation.
3. Determine the magnitude and phase response of the given equation
y(n) =x(n)+x(n-2) .
4. Determine the frequency response for the system given by
y(n)-y3/4y(n-1)+1/8 y(n-2) = x(n)- x(n-1).
5. Determine the pole and zero plot for the system described difference equations
y(n)=x(n)+2x(n-1)-4x(n-2)+x(n-3).
6. Find the output of the system whose input- output is related by the difference equation
y(n) -5/6 y(n-1) +1/6 y(n-2) = x(n) -1/2 x(n-1) for the step input.
7. Find the output of the system whose input- output is related by the difference equation
y(n) -5/6 y(n-1) +1/6 y(n-2) = x(n) -1/2 x(n-1) for the x(n) =4 n u(n).

32 | D S P L A B Department of ECE
EXPERIMENT 8

IMPLEMENTATION OF LP FIR FILTER FOR A GIVEN SEQUENCE

AIM:
Design LP FIR filter and verify with different cutoff frequencies using matlab software.

EQUIPMENTS:

Host (PC) with windows (95/98/Me/XP/NT/2000), mat lab software

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.

THEORY:

A Finite Impulse Response (FIR) filter is a discrete linear time-invariant system whose output is based
on the weighted summation of a finite number of past inputs. An FIR transversal filter structure can be
obtained directly from the equation for discrete-time convolution.
N 1
y ( n)   x ( k ) h( n  k ) 0  n  N  1
k 0
In this equation, x(k) and y(n) represent the input to and output from the filter at time n. h(n-k) is the
transversal filter coefficients at time n.

FIR filters are digital filters with finite impulse response. They are also known as non-recursive
digital filters as they do not have the feedback (a recursive part of a filter), even though recursive
algorithms can be used for FIR filter realization.

Finite impulse response (FIR) filter design methods:

Most FIR filter design methods are based on ideal filter approximation. The resulting filter approximates
the ideal characteristic as the filter order increases, thus making the filter and its implementation more
complex.

The filter design process starts with specifications and requirements of the desirable FIR filter. Which
method is to be used in the filter design process depends on the filter specifications and implementation.
This chapter discusses the FIR filter design method using window functions.
33 | D S P L A B Department of ECE
Each of the given methods has its advantages and disadvantages. Thus, it is very important to carefully
choose the right method for FIR filter design. Due to its simplicity and efficiency, the window method is
most commonly used method for designing filters. The sampling frequency method is easy to use, but
filters designed this way have small attenuation in the stopband.

As we have mentioned above, the design process starts with the specification of desirable FIR filter.

Basic concepts and FIR filter specification


First of all, it is necessay to learn the basic concepts that will be used further in this book. You should be
aware that without being familiar with these concepts, it is not possible to understand analyses and
synthesis of digital filters.

Figure 1 illustrates a low-pass digital filter specification. The word specification actually refers to the
frequency response specification.

Figure 1. Low-pass digital filter specification

 ωp – normalized cut-off frequency in the passband;


 ωs – normalized cut-off frequency in the stopband;
 δ1 – maximum ripples in the passband;
 δ2 – minimum attenuation in the stopband [dB];
 ap – maximum ripples in the passband; and
 as – minimum attenuation in the stopband [dB].

Frequency normalization can be expressed as follows

where:

34 | D S P L A B Department of ECE
 fs is a sampling frequency;
 f is a frequency to normalize; and
 ω is normalized frequency.

PROGRAM:

n=20;

fp=200;

fq=300;

fs=1000;

fn=2*fp/fs;

window=rectwin(n+1);

b=fir1(n,fn,window);

[H W]=freqz(b,1,128);

subplot(2,1,1);

plot(W/pi,abs(H));

title('magnitude response of lpf');

ylabel('gain in db-------->');

xlabel('normalized frequency------>');

subplot(2,1,2);

plot(W/pi,angle(H));

title('phase response of lpf');

ylabel('angle-------->');

xlabel('normalized frequency------>');

35 | D S P L A B Department of ECE
OUTPUT:

FIGURE: Frequency response of the LP-FIR filter using Rectangular window

%Program for FIR LPF using blackman window

n=20;

fp=200;

fq=300;

fs=1000;

fn=2*fp/fs;

window=blackman(n+1);

b=fir1(n,fn,window);

[H W]=freqz(b,1,128);

subplot(2,1,1);

plot(W/pi,abs(H));

title('magnitude response of lpf');

36 | D S P L A B Department of ECE
ylabel('gain in db-------->');

xlabel('normalized frequency------>');

subplot(2,1,2);

plot(W/pi,angle(H));

title('phase response of lpf');

ylabel('angle-------->');

xlabel('normalized frequency------>');

OUTPUT:

FIGURE: Frequency response of the LP-FIR filter using Blackman window

RESULT:

Frequency Response of the LP-FIR filter is calculated using window technique.

37 | D S P L A B Department of ECE
VIVA QUESTIONS:

1. Define an FIR filter.


2. Compare IIR and FIR filters.
3. What are the desirable characteristics of windows?
4. Write the steps involved in FIR filter design.
5. Define ripples in a filter.
6. What are the design techniques of designing FIR filters?
7. . What is the draw back in FIR filter design using windows and frequency sampling method?
8. . Write the characteristic features of rectangular and triangular window.
9. Why triangular window is not a good choice for designing FIR filters?
10. Draw the direct form realization of FIR system.

38 | D S P L A B Department of ECE
EXPRIMENT: 9

IMPLEMENTATION OF HP IIR FILTER FOR A GIVEN SEQUENCE

AIM: - TO write a MATLAB program to Amplitude response and response of Butter worth high pass
filter

EQUIPMENTS:- Host (PC) with windows (95/98/Me/XP/NT/2000), mat lab software

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. Using Butter worth or Chebbyshew filter design IIR filter.

6. Draw the magnitude and phase responses.

THEORY:
The IIR filter can realize both the poles and zeroes of a system because it has a rational transfer
function, described by polynomials in z in both the numerator and the denominator:
M

b
k 0
k z k
H ( z) N

a
k 1
k Z k

The difference equation for such a system is described by the following:


M N
y ( n )   bk x ( n  k )  a k y (n  k )
k 0 k 1

M and N are order of the two polynomials, bk and ak are the filter coefficients.
IIR filters are digital filters with infinite impulse response. Unlike FIR filters, they have the feedback
(a recursive part of a filter) and are known as recursive digital filters.
For this reason IIR filters have much better frequency response than FIR filters of the same order.
Unlike FIR filters, their phase characteristic is not linear which can cause a problem to the systems
which need phase linearity. For this reason, it is not preferable to use IIR filters in digital signal

39 | D S P L A B Department of ECE
processing when the phase is of the essence. Otherwise, when the linear phase characteristic is not
important, the use of IIR filters is an excellent solution.

The most commonly used IIR filter design method uses reference analog prototype filter. It is the best
method to use when designing standard filters such as low-pass, high-pass, bandpass and band-stop
filters.
Figure 1 illustrates a High-pass digital filter specification. The word specification refers to the
frequency response specification.

Figure 1. High-pass IIR digital filter specification

 ωp – normalized passband cut-off frequency;


 ωs – normalized stopband cut-off frequency;
 δ1 – maximum passband ripples;
 δ2 – minimum stopband attentuation;
 ε – passband attenuation parameter;
 A – stopband attenuation parameter;
 ap – maximum passband ripples [dB]; and
 as – minimum stopband attenuation [dB].

40 | D S P L A B Department of ECE
Frequency normalization can be expressed as follows:

where:

 fs is the sampling frequency;


 f is the frequency to normalize; and
 ω is the normalized frequency.

PROGRAM:-

clc;

close all;

clear all;

format long;

rp=input('enter the passband ripple');

rs=input('enter the stopband ripple');

wp=input('enter the passband frequency');

ws=input('enter the stopband frequency');

fs=input('enter the sampling frequency');

w1=2*wp/fs;

w2=2*ws/fs;

[n,wn]=buttord(w1,w2,rp,rs,'s');

[z,p,k]= butter(n,wn);

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

41 | D S P L A B Department of ECE
w=0:0.01:pi;

[h,om]=freqs(b,a,w);

m=20*log10(abs(h));

an=angle(h);

subplot(2,1,1);

plot(om/pi,m);

ylabel('gain in db--------->');

xlabel('(a) normalized freq------>');

subplot(2,1,2);

plot(om/pi,an);

ylabel('phase in db--------->');

xlabel('(b) normalized freq------>');

42 | D S P L A B Department of ECE
INPUT

Enter the passband ripple .2

Enter the stopband ripple 40

Enter the passband frequency 2000

Enter the stopband frequency 3500

Enter the sampling frequency 8000

OUTPUT

Figure: Frequency response of the HP-IIR filter using Butterworth filter

RESULT: The HP-IIR filter using Butterworth analog filter is implemented.

VIVA QUESTIONS:

1. Define an IIR filter.


2. Compare IIR and FIR filters.
3. Define ripples in a filter.
43 | D S P L A B Department of ECE
4. Write a brief note on the design of IIR filter. (Or how a digital IIRfilter is designed?)
5. Mention any two techniques for digitizing the transfer function of an analog filter.
6. Mention the important features of IIR filters.
7. What is impulse invariant transformation?
8. How analog poles are mapped to digital poles in impulse invariant transformation (or in bilinear
transformation)?
9. What is the relation between digital and analog frequency in impulse invariant transformation?
10. What is aliasing problem in impulse invariant method of designing digital filters? Why it is absent
in bilinear transformation?
11. What is bilinear transformation?

44 | D S P L A B Department of ECE
EXPERIMENT ; 10

GENERATION OF SINUSOIDAL SIGNAL THROUGH FILTERING

AIM: Generation of Sinusoidal signal through filtering.

EQUIPMENTS NEEDED:
Host (PC) with windows (95/98/Me/XP/NT/2000), matlab software

ALGORITHM:

1. Enter the sampling frequency.

2. Enter the Signal frequency.

3. Calculate the coefficients of x(n) & y(n).

4. Using the Filter generate the sinusoidal signal.


5. Draw the Signal and its spectrum.

THEORY:

A digital filter is characterized by its transfer function, or equivalently, its difference equation.
Mathematical analysis of the transfer function can describe how it will respond to any input. As such,
designing a filter consists of developing specifications appropriate to the problem (for example, a second-
order low pass filter with a specific cut-off frequency), and then producing a transfer function which meets
the specifications.

The transfer function for a linear, time-invariant, digital filter can be expressed as a transfer function in
the Z-domain; if it is causal, then it has the form:

where the order of the filter is the greater of N or M.

This is the form for a recursive filter with both the inputs (Numerator) and outputs (Denominator),
which typically leads to an IIR infinite impulse response behavior, but if the denominator is made
equal to unity i.e. no feedback, then this becomes an FIR or finite impulse response filter.

45 | D S P L A B Department of ECE
PROGRAM

clc;

close all;

clear all;

%% Signal Frequency and Sampling frequency

% f_hz=input('enter the signal frequency in Hz= ');

% fs=input('enter the sampling frequency which is greater than twice the signal frequency= ');

f_hz=1000; % Signal frequency (Change this value and test)

fs=8000; % Sampling frequency (change this value and test)

f0=2*pi*f_hz/fs; % Sampled Signal Frequency in Radians

t=0:1/fs:1; % Time Vector for 1 Second duration

x=zeros(1,length(t)); % Initializing the input sequence to zero

x(1)=1; % Impulse input

%% Calculation of numerator coefficients

b0=0;

b1=sin(f0);

%% Calculation of denominator coefficients

a0=1;

a1=-2*cos(f0);

a2=1;

b=[b0 b1]; % Numerator coefficients

a=[a0 a1 a2]; % Denominator coefficients

%% Filtering Operation

y=filter(b,a,x);

%% Plot of Signal and its Spectrum

subplot(2,1,1)

plot(t(1:200),y(1:200)); % Select only 200 points for clear plot

xlabel('Time in Seconds');

ylabel('Amplitude of the Signal');

46 | D S P L A B Department of ECE
title(['Sinusoidal Signal of frequency ', num2str(f_hz), ' Hz']);

% One Sided spectrum

Ak=2*abs(fft(y))/length(y); % Finding FFT

Ak(1)=Ak(1)/2;

f=(0:1:(length(y)-1)/2)*fs/length(y); % Indices to frequencies in Hz for plotting

subplot(2,1,2)

plot(f,Ak(1:(length(y)+1)/2)); % Plot upto folding frequency

xlabel('Frequency in Hz')

ylabel('Magnetude of the Spectrum');

title(['Spectrum at ', num2str(f_hz), ' Hz frequency']);

OUTPUT

Figure 1: A 1000Hz sine signal with its spectrum

RESULT: A sinusoidal signal is generated using filter.

47 | D S P L A B Department of ECE
VIVA QUESTIONS:

1. Define various types of the filter.


2. Compare analog and digital filters.
3. How to convert analog filter into digital filter.
4. What is Recursive Filter.
5. What is Non-Recursive Filter.
6. Which filter is called Recursive Filter.
7. Which filter is called Non-Recursive Filter.
8. Write the first order Recursive difference equation.
9. Write the second order Recursive difference equation coefficients.

48 | D S P L A B Department of ECE
EXPERIMENT : 11

GENERATION OF DTMF SIGNALS

AIM: Generation of DTMF signals.

EQUIPMENTS NEEDED:
Host (PC) with windows (95/98/Me/XP/NT/2000), matlab software

ALGORITHM:

1. Enter the sampling frequency.

2. Enter the Signal frequency.

3. Enter low and high frequency values

4. Generate the signal for low and high frequencies.


5. Draw the Signal and its spectrum.

THEORY:

DTMF (Dual tone multi frequency) as the name suggests uses a combination of two sine wave tones to
represent a key. These tones are called row and column frequencies as they correspond to the layout of a
telephone keypad.

49 | D S P L A B Department of ECE
DTMF keypad (generator or encoder) generates a sinusoidal tone which is mixture of the row and
column frequencies. The row frequencies are low group frequencies. The column frequencies belong to
high group frequencies. This prevents misinterpretation of the harmonics. Also the frequencies
for DTMF are so chosen that none have a harmonic relationship with the others and that mixing the
frequencies would not produce sum or product frequencies that could mimic another valid tone. The high-
group frequencies (the column tones) are slightly louder than the low-group to compensate for the high-
frequency roll off of voice audio systems.
The row and column frequencies corresponding to a DTMF keypad have been indicated in the
above figure.
DTMF tones are able to represent one of the 16 different states or symbols on the keypad. This is
equivalent to 4 bits of data, also known as nibble.

TMF - Mark & Space details

Mark and Space refer to the duration a Dtmf tone is produced, as well as the duration of the silence
between individual digits.

The time which a DTMF digit tone is actually producing sound, is called the "Mark" time. The silence
between each one of the digits is called the "Space". Most DTMF decoders and controllers will list a
minimum Mark/Space speed, expressed in milliseconds.

The standard for most radio decoders, as well as most telephone equipment is 40/40. The decoders expect
the DTMF tones to exist for at least 40 milliseconds, with 40 milliseconds of silence in between each
DTMF digit.

PROGRAM:

clc;

close all;

clear all;

% Program for generation of DTMF Signal

%% Signal Frequency and Sampling frequency

50 | D S P L A B Department of ECE
% fs=input('enter the sampling frequency which is greater than twice the max. signal frequency= ');

fs=8000; % Sampling frequency (change this value and test)

t=0:1/fs:1; % Time Vector for 1 Second duration with spacing of 1/fs

x=zeros(1,length(t)); % Initializing the input sequence to zero

x(1)=1; % Impulse input

%% Calculation of output of LF signal generation System

%fL=input('enter any one low frequency value from [697 770 852 941] vector= ');

fL=852; %For ex. fL=852 Hz;

% Numerator coefficients of HL(z)

bL=[0 sin(2*pi*fL/fs)];

% Denominator coefficients of HL(z)

aL=[1 -2*cos(2*pi*fL/fs) 1];

% Output of HL(z)

yL=filter(bL,aL,x);

%% Calculation of output of HF signal generation System

%fH=input('enter any one High frequency value from [1209 1336 1477] vector= ');

fH=1336; %For ex. fH=1336 Hz;

% Numerator coefficients of HH(z)

bH=[0 sin(2*pi*fH/fs)];

% Denominator coefficients of HH(z)

aH=[1 -2*cos(2*pi*fH/fs) 1];

% Output of HH(z)

yH=filter(bH,aH,x);

% Generation of fL & fH DTMF tone

y_LH=yL+yH;

%% Identifying key pressed

if(fL==697 && fH==1209)

key=1;

51 | D S P L A B Department of ECE
disp(' Generated DTMF tone is for key 1');

end

if(fL==697 && fH==1336)

key=2;

disp(' Generated DTMF tone is for key 2');

end

if(fL==697 && fH==1477)

key=3;

disp(' Generated DTMF tone is for key 3');

end

if(fL==770 && fH==1209)

key=4;

disp(' Generated DTMF tone is for key 4');

end

if(fL==770 && fH==1336)

key=5;

disp(' Generated DTMF tone is for key 5');

end

if(fL==770 && fH==1477)

key=6;

disp(' Generated DTMF tone is for key 6');

end

if(fL==852 && fH==1209)

key=7;

disp(' Generated DTMF tone is for key 7');

end

if(fL==852 && fH==1336)

key=8;

disp(' Generated DTMF tone is for key 8');

52 | D S P L A B Department of ECE
end

if(fL==852 && fH==1477)

key=9;

disp(' Generated DTMF tone is for key 9');

end

if(fL==941 && fH==1209)

key='*';

disp(' Generated DTMF tone is for key *');

end

if(fL==941 && fH==1336)

key=0;

disp(' Generated DTMF tone is for key 0');

end

if(fL==941 && fH==1477)

key='#';

disp(' Generated DTMF tone is for key #');

end

%% Plot of DTMF Signal and its Spectrum

subplot(2,1,1)

plot(t(1:200),y_LH(1:200)); % Select only 200 points for clear plot

xlabel('Time in Seconds');

ylabel('Amplitude of DTMF Signal');

title(['DTMF Signal waveform for key ',num2str(key)]);

% One Sided Amplitude spectrum

Mag_spec=2*abs(fft(y_LH))/length(y_LH); % Finding FFT

Mag_spec(1)=Mag_spec(1)/2;

f=(0:1:(length(y_LH)-1)/2)*fs/length(y_LH); % Mapping frequency indices in Hz for plotting

subplot(2,1,2)

53 | D S P L A B Department of ECE
plot(f,Mag_spec(1:(length(y_LH)+1)/2)); % Plot upto folding frequency

grid

xlabel('Frequency in Hz')

ylabel('Magnetude of the Spectrum');

title(['Magnetude Spectrum of DTMF Tone for key ', num2str(key),' at ' num2str(fL),' Hz & at ',
num2str(fH),' Hz']);

OUTPUT

Figure: Generated DTMF tone is for key 8

RESULT: DTMF tone is generated for selected number.

54 | D S P L A B Department of ECE
VIVA QUESTIONS:

1. Define the Dual Tone Multiple Frequency signal.


2. Explain how the tone is generated using DTMF.
3. What are the upper frequencies of DTMF.
4. What are the lower frequencies of DTMF.
5. What is Mark.
6. What is Space.

55 | D S P L A B Department of ECE
EXPERIMENT: 12

IMPLEMENTATION OF DECIMATION PROCESS

AIM: To verify Decimation of a given Sequences.

EQUIPMENTS REQUIRED:
Host (PC) with windows (95/98/Me/XP/NT/2000), matlab software.

ALGORITHM:
1. Generate the discrete signal.
2. Calculate the length of the signal.
3. Perform Down Sampling operation using a factor.
4. Draw the Down Sampled signal.

THEORY:

The sampling rate alteration that is employed to generate a new sequence with a sampling rate higher or
lower than that of a given sequence. Thus, if x[n] is a sequence with a sampling rate of F T Hz and it is
used to generate another sequence y[n] with a desired sampling rate of FT' Hz, then the sampling rate
alteration ratio is given by FT' / FT = R.

If R < 1, the sampling rate is decreased by a process called decimation and it results in a sequence with a
lower sampling rate.

The decimation can be carried out by using the pre-defined commands decimate.

PROGRAM:

clc;

clear all;

close all;

disp('Let us take a sinusoidal sequence which has to be decimated: ');

fm=input('Enter the signal frequency fm: ');

fs=input('Enetr the sampling frequnecy fs: ');

T=input('Enter the duration of the signal in seconds T: ');

56 | D S P L A B Department of ECE
dt=1/fs;

t=dt:dt:T

M=length(t);

m=cos(2*pi*fm*t);

r=input('Enter the factor by which the sampling frequency has to be reduced r: ');

md=decimate(m,r);

figure(1);

subplot(3,1,1);

plot(t,m);

grid;

xlabel('t-->');

ylabel('Amplitude-->');

title('Sinusoidal signal before sampling');

subplot(3,1,2);

stem(m);

grid;

xlabel('n-->');

ylabel('Amplitudes of m -->');

title('Sinusoidal signal after sampling before decimation');

subplot(3,1,3);

stem(md);

grid;

title('Sinusoidal after decimation');

xlabel('n/r-->');

ylabel('Amplitude of md-->');

57 | D S P L A B Department of ECE
OUTPUT

Let us take a sinusoidal sequence which has to be decimated:

Enter the signal frequency fm: 0.1

Enetr the sampling frequnecy fs: 10

Enter the duration of the signal in seconds T: 5

Enter the factor by which the sampling frequency has to be reduced r: 3

Figure: A sine signal before Decimation & after decimation

RESULT: Decimation operation is performed on signal.

58 | D S P L A B Department of ECE
VIVA QUESTIONS:

1. What is multirate signal processing?


2. Define down sampling.
3. What is meant by up sampling?
4. What is the need for anti-aliasing filter prior to down sampling?
5. What is the need for anti- imaging filter after up sampling?
6. Define sampling rate conversion.
7. Mention two applications of multirate signal processing.
8. What is decimator?
9. What you mean by sub band coding?
10. What is an anti- image filter?

59 | D S P L A B Department of ECE
EXPERIMENT : 13

IMPLEMENTATION OF INTERPOLATION PROCESS

AIM: To verify Interpolation of a given Sequences.

EQUIPMENTS REQUIRED:

Host (PC) with windows (95/98/Me/XP/NT/2000), matlab software.

ALGORITHM:
1. Generate the discrete signal.
2. Calculate the length of the signal.
3. Perform Up Sampling operation using a factor.
4. Draw the Up Sampled signal.

THEORY:

The sampling rate alteration that is employed to generate a new sequence with a sampling rate higher or
lower than that of a given sequence. Thus, if x[n] is a sequence with a sampling rate of F T Hz and it is
used to generate another sequence y[n] with a desired sampling rate of FT' Hz, then the sampling rate
alteration ratio is given by FT' / FT = R.

If R > 1, the process is called interpolation and results in a sequence with a higher sampling rate.

The interpolation can be carried out by using the pre-defined interp.

PROGRAM:

clc;

clear all;

close all;

disp('Let us take a sinusoidal sequence which has to be interpolated: ');

fm=input('Enter the signal frequency fm: ');

fs=input('Enetr the sampling frequnecy fs: ');

T=input('Enter the duration of the signal in seconds T: ');

dt=1/fs;

t=dt:dt:T

M=length(t);
60 | D S P L A B Department of ECE
m=cos(2*pi*fm*t);

r=input('Enter the factor by which the sampling frequency has to be increased r: ');

md=interp(m,r);

figure(1);

subplot(3,1,1);

plot(t,m);

grid;

xlabel('t-->');

ylabel('Amplitude-->');

title('Sinusoidal signal before sampling');

subplot(3,1,2);

stem(m);

grid;

xlabel('n-->');

ylabel('Amplitudes of m -->');

title('Sinusoidal signal after sampling before interpolation');

subplot(3,1,3);

stem(md);

grid;

title('Sinusoidal after interpolation');

xlabel('n x r-->');

ylabel('Amplitude of md-->');

OUTPUT

Let us take a sinusoidal sequence which has to be interpolated:

Enter the signal frequency fm: 0.1

Enetr the sampling frequnecy fs: 10

Enter the duration of the signal in seconds T: 5

Enter the factor by which the sampling frequency has to be increased r: 2

61 | D S P L A B Department of ECE
Figure: A sine signal before Interpolation & after Interpolation

RESULT: Decimation operation is performed on signal.

VIVA QUESTIONS:

1. What is multirate signal processing?


2. What is meant by up sampling?
3. What is the need for anti-aliasing filter prior to down sampling?
4. What is the need for anti- imaging filter after up sampling?
5. Define sampling rate conversion.
6. Mention two applications of multirate signal processing.
7. What is decimator?
8. What you mean by sub band coding?
9. What is an anti- image filter?

62 | D S P L A B Department of ECE
EXPERIMENT: 14

IMPLEMENTATION OF I/D SAMPLING RATE CONVERTERS

AIM:

To implement the I/D sampling converts using matlab software.

EQUIPMENTS REQUIRED:
Host (PC) with windows (95/98/Me/XP/NT/2000), matlab software
THEORY:

Considering the general case of sampling rate conversion by a rational factor input basically we can
achieve this sampling rate conversion by performing interpolation by the factor output of the I/D is
accomplished by cascading and interpolation by the denominator. The filter with the impuse response {
h(k) & hd(k)} input is decomplished by cascading and interpolation with a denominator.

M L

PROGRAM:

clc

clear all

close all

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

L=input('enter the UP sampling factor = ');

M=input('enter the DOWN Sampling factor= ');

N=input('enter number of samples= ');

n=0:N-1;

x= sin(2*pi*0.043*n)+sin(2*pi*0.031*n);

y=resample(x,L,M);

subplot(2,1,1);

stem(n,x(1:N));

xlabel(‘time-’);

63 | D S P L A B Department of ECE
ylabel(‘amplitude-’);

title(‘input sequence’);

subplot(2,1,2);

stem(y(1:N*L/M));

xlabel(‘time’);

ylabel(‘amplitude’);

title(‘output sequence’);

Result:- Hence the implementation of I/D sampling rate conversion was observed by using matlab
software.

64 | D S P L A B Department of ECE
EXPERIMENT : 15

IMPULSE RESPONSE OF FIRST ORDER AND SECOND ORDER SYSTEMS

AIM:

Find the impulse response of first order and second order systems.

EQUIPMENTS REQUIRED:
Host (PC) with windows (95/98/Me/XP/NT/2000), matlab software

ALGORITHM:

1. Enter the coefficients of denominator polynomial.

2. Enter the coefficients of numerator polynomial.

3. Obtain the system equation for this coefficient.

4. Find the impulse response of first order and second order systems.

THEORY:

A system's impulse response (often annotated as h(t)for continuous-time systems or h[n] for discrete-time
systems) is defined as the output signal that results when an impulse is applied to the system input. The
impulse response of the system is given as,

where h[n] is the system's impulse response. The above equation is the convolution theorem for discrete-
time LTI systems. That is, for any signal x[n] that is input to an LTI system, the system's output y[n] is
equal to the discrete convolution of the input signal and the system's impulse response.

PROGRAM:

clc

clear all

close all

65 | D S P L A B Department of ECE
% y(n0=y(n-1)+0.9y(n-2)=x(n)+0.5x(n-1)+0.5x(n-2)

%a=input('enter the coefficients of denominator polynomial= ');

%b=input('enter the coefcients of numerator polynomial= ');

a=[1 1 0.9];

b=[1 0.5 0.5];

N=20; % length of input sequence

x=[1 zeros(1,N)];

y=filter(b,a,x);

subplot(2,1,1)

stem(1:length(x),x);

xlabel('Time');

ylabel('Amplitude');

title('Impulse Sequence');

subplot(2,1,2)

stem(1:length(y),y);

xlabel('Time');

ylabel('Amplitude');

title('Impulse Response Sequence');

66 | D S P L A B Department of ECE
OUTPUT

Figure: The impulse response of the sequence

RESULT: The impulse response of first order and second order systems are obtained.

VIVA QUESTIONS:

1. Define impulse response of the system.


2. Define convolution operation.
3. Which system is called LTI system.
4. Define causal & non-causal system.
5. What is zero input system.
6. What is infinite impulse response.
7. What is finite impulse response..

67 | D S P L A B Department of ECE

Potrebbero piacerti anche