0% found this document useful (0 votes)
2 views

DSP LAB MANUAL

The document is a lab manual for the Digital Signal Processing Laboratory for B. Tech (ECE) students, detailing various experiments to be conducted. It includes a list of experiments such as generating sinusoidal waveforms, analyzing noise histograms, and finding DFT/IDFT of signals, along with the required equipment, algorithms, and theoretical background for each experiment. Additionally, it provides MATLAB programs for practical implementation and includes viva questions for assessment.

Uploaded by

Abhinay Gude
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

DSP LAB MANUAL

The document is a lab manual for the Digital Signal Processing Laboratory for B. Tech (ECE) students, detailing various experiments to be conducted. It includes a list of experiments such as generating sinusoidal waveforms, analyzing noise histograms, and finding DFT/IDFT of signals, along with the required equipment, algorithms, and theoretical background for each experiment. Additionally, it provides MATLAB programs for practical implementation and includes viva questions for assessment.

Uploaded by

Abhinay Gude
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 64

DEPARTMENT OF ECE

DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING

Digital Signal Processing Laboratory


Lab Manual
(As per Autonomous – R-22 Regulation)

B. Tech (ECE) - VI Sem.

Prepared by
Dr. R. Bhargav Ram
Mr B. Venkata Ramana

CMR COLLEGE OF ENGINEERING & TECHNOLOGY


(An Autonomous Institution)
KANDLAKOYA, MEDCHAL ROAD, HYDERABAD – 501401

1
DEPARTMENT OF ECE

LIST OF EXPERIMENTS

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


2. Histogram of White Gaussian Noise and Unifromly 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, FFT and compare for half sine wave.
6. Implementation of FFT of given sequence
7. Determination of Power Spectrum of a given sequence.
8. Implementation of LP FIR filter for a given sequence.
9. Implementation of HP IIR filter for a given sequence.
10. Generation of Sinusoidal 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 system

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

3
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)
4
DEPARTMENT OF ECE

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

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']);

OUTPUT:

Figure 1: A 1000Hz sine signal with its spectrum

RESULT:

A sinusoidal signal is generated using Recursive difference equation.

5
DEPARTMENT OF ECE

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.

6
DEPARTMENT OF ECE

EXPERIMENT 2
HISTOGRAM OF WHITE GAUSSIAN NOISE AND UNIFORMLY DISTRIBUTED NOISE

Aim: To generate histogram of white Gaussian noise and uniformly distributed noise using
matlab software

EQUIPMENT: PC with windows (95/98/XP/NT/2000).

MATLAB Software

ALGORITHM:
1. Enter the mean and standard deviation.
2. Create white Gaussian noise and Uniformly distributed noise
3. Generate histogram of noises
THEORY:
generate a Gaussian white noise signal of length L=100,000 using the randn function
in Matlab and plot it. Let’s assume that the pdf is a Gaussian pdf with mean μ=0 and
standard deviation σ=2. Thus the variance of the Gaussian pdf is σ2=4. The
theoretical PDF of Gaussian random variable is given by

PROGRAM:

clc;

clear all; close


all; l=10000;

mu=input('enter the mean value');

sigma=input('enter the standard deviation');

n=input('enter the number of bins');


x=sigma*randn(1,l)+mu;

y=sigma*rand(1,l)+mu;
[f1,x1]=hist(x,n);
[f2,y2]=hist(y,n);

7
DEPARTMENT OF ECE

subplot(2,2,1); plot(x);
xlabel('time');
ylabel('amplitude');

title('white gaussian noise'); subplot(2,2,2);

bar(x1,f1); xlabel('number of bars');

ylabel('probability of occurance'); title('histogram of white


gaussian'); subplot(2,2,3);

plot(y); xlabel('time');
ylabel('amplitude');

title('uniform distributed noise'); subplot(2,2,4);

bar(y2,f2); xlabel('number of bars');

ylabel('probability of occurance'); title('histogram of uniformly


distributed noise');

OUTPUT:

RESULT:
The histogram of uniformly distributed and white gaussian noise are generated
8
DEPARTMENT OF ECE

Viva Questions

1. What is white Gaussian noise?


2. What is uniformly distributed noise?
3. How can you generate white Gaussian noise?
4. How can you generate uniformly distributed noise?
5. What is the difference between the histograms of white Gaussian noise and uniformly distributed
noise?

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

10
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);

disp(xk)

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

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

title('DFT sequence');

% Magnitude Spectrum of DFT sequence

y=abs(xk);

subplot(2,2,3);

stem(k,y)

11
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

% IDFT of a given DFT sequence

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

N=length(x);
12
DEPARTMENT OF ECE

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);disp(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

z=angle(xn);

subplot(2,2,4);

stem(n,z)

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

13
DEPARTMENT OF ECE

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.

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?

14
DEPARTMENT OF ECE

EXPERIMENT 4

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


FUNCTION/ DIFFERENCE 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.

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

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

17
DEPARTMENT OF ECE

EXPERIMENT:5
OBTAIN FOURIER SERIES COEFFICIENTS BY FORMULA, FFT AND COMPARE FOR
HALF SINE WAVE

AIM:

To obtain Fourier series coefficients by formula, fft and compare for half sine wave

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

ALGORITHM:

1. Obtain fourier series coefficients for half sine wave

2. Obtain fft coefficients for half sine wave

3. Compare the coefficents

THEORY:

Fourier series and the Fast Fourier Transform (FFT) are two powerful mathematical tools used to analyze
and understand complex signals. They help us break down signals into their fundamental components,
revealing hidden patterns and insights that might be invisible in the original form.

Imagine a musical chord played on a piano. While it sounds like a single note, it's actually a combination
of multiple pure tones at different frequencies. Fourier series decomposes this complex sound wave into
its constituent sine and cosine waves, each with a specific frequency and amplitude

The FFT is a computational algorithm that efficiently calculates the Fourier transform of a discrete signal.
It's essentially a "fast track" for applying Fourier series analysis to digital data, making it incredibly useful
in various fields.

The FFT can be seen as a practical implementation of the Fourier series for discrete signals. It allows us to
quickly analyze real-world data that wouldn't be feasible with traditional Fourier series calculations.

PROGRAM:

% Define function and period


T = 10;
x = linspace(0, T, 1024); % Sampling points
y = sin(pi*x);
y1=y>0;

% Formula method
a0 = (2/T) * trapz(x, y); % Trapezoidal integration for a0
an = zeros(1, 5); % Allocate space for 5 coefficients (adjust as
needed)
for n = 1:5
an(n) = (2/T) * trapz(x, y .* cos(n*pi*x/T)); % Integration for an
end
18
DEPARTMENT OF ECE

% FFT method
yf = fft(y);
fft_a0 = yf(1)/length(yf); % DC component from FFT
fft_an = 2*yf(2:end/2+1)/length(yf); % Symmetric spectrum for positive
frequencies

% Compare coefficients
disp('Coefficients from formula:')
disp(['a0: ' num2str(a0)])
disp(['an: ' num2str(an)])

disp('Coefficients from FFT:')


disp(['a0: ' num2str(fft_a0)])
disp(['an: ' num2str(fft_an)])

% Plot the results (optional)


figure;
subplot(2,1,1);
plot(x(y1), y(y1));
title('Half-sine wave');
subplot(2,1,2);
stem(0:5, [a0 an], 'g');
hold on;
stem(1:6, [fft_a0 fft_an],'b');
legend('Formula', 'FFT');
title('Fourier coefficients');

OUTPUT:

19
DEPARTMENT OF ECE

RESULT:

The comparison for fourier series coefficients and FFT coefficiencts is obtained.

VIVA QUESTIONS:

1. Explain the key differences between Fourier series and the Fast Fourier Transform (FFT).
2. What is the significance of the fundamental frequency in Fourier series?
3. Describe the relationship between the coefficients (a_n and b_n) and the frequency components of
a signal.
4. Why do we need the FFT? Can't we just use Fourier series directly for all signal analysis?
5. Explain the concept of aliasing in the context of the FFT.

20
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 ( 2n )
n =0
WN2 nk

21
DEPARTMENT OF ECE

would result in

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
WNnk = 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
= WNk (−1) = W 
N
2
= WNk
22
DEPARTMENT OF ECE

Employing this equation, we deduce

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.

23
DEPARTMENT OF ECE

STAGE – I STAGE - II

STAGE – III

FIG. 8 POINT DIT

24
DEPARTMENT OF ECE

PROGRAM:

%% Clear Section

clear all;

close all;

clc;

Fs = 1000;

T = 1/ Fs;

t = 0:T:1;

y = sin ( 2 * pi * 200 * t ); % generates sine wave of 200Hz

plot(y)

z = fft(y,1024); % gets 1024 point fft for y

N =( 0 :1023 )' * Fs / 1024;

z1 = abs(z);

subplot(2,1,1)

plot( N, z1)

title(' FFT Plot ' )

z2 = angle (z);

subplot(2,1,2)

plot( N, z2 )

title( ' Phase Plot ')

25
DEPARTMENT OF ECE

OUTPUT:

Figure: Magnitude & Phase plot of FFT sequence

RESULT:

FFT of a given sequence is obtained.

26
DEPARTMENT OF ECE

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
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


T
− j 2ft
S x ( f ) = lim E  x(t )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
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
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
DEPARTMENT OF ECE

Output:

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

4
x 10 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)

Power Spectral Density


0.08

0.07

0.06

0.05
abs(Sxx)

0.04

0.03

0.02

0.01

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

Result: The power spectrum of given signals are found


31
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
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
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
DEPARTMENT OF ECE

➢ fs is a sampling frequency;
➢ f is a frequency to normalize; and
➢ ω is normalized frequency.

PROGR

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------>');

OUTPUT:

35
DEPARTMENT OF ECE

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');

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

36
DEPARTMENT OF ECE

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

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.

39
DEPARTMENT OF ECE

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
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');

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

w=0:0.01:pi;

41
DEPARTMENT OF ECE

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

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

an=angle(h);

subplot(2,1,1);

plot(om/pi,m);grid;

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

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

subplot(2,1,2);

plot(om/pi,an); grid;

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

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

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

42
DEPARTMENT OF ECE

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

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

PROGRAM

clc;

close all;

clear all;

44
DEPARTMENT OF ECE

%% 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');

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;

45
DEPARTMENT OF ECE

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.

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.

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

47
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
figure(1)
% DTMF tone generator
fs=8000;
t=[0:1:204]/fs;

48
DEPARTMENT OF ECE

x=zeros(1,length(t));
x(1)=1;
y852=filter([0 sin(2*pi*852/fs) ],[1 -2*cos(2*pi*852/fs) 1],x);
y1209=filter([0 sin(2*pi*1209/fs) ],[1 -2*cos(2*pi*1209/fs) 1],x);
y7=y852+y1209;
subplot(2,1,1);plot(t,y7);grid
ylabel(' y(n) DTMF: number 7');
xlabel(' time (second)')
Ak=2*abs(fft(y7))/length(y7);Ak(1)=Ak(1)/2;
f=[0:1:(length(y7)-1)/2]*fs/length(y7);
subplot(2,1,2);
plot(f,Ak(1:(length(y7)+1)/2));grid
ylabel('Spectrum for y7(n)');
xlabel(' frequency (Hz)');

OUTPUT

Figure: Generated DTMF tone is for key 7

RESULT: DTMF tone is generated for selected number.

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

50
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: ');

dt=1/fs;

t=dt:dt:T

m=cos(2*pi*fm*t);
51
DEPARTMENT OF ECE

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-->');

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

52
DEPARTMENT OF ECE

Figure: A sine signal before Decimation & after decimation

RESULT: Decimation operation is performed on signal.

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?

53
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);

m=cos(2*pi*fm*t);
54
DEPARTMENT OF ECE

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

55
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?

56
DEPARTMENT OF ECE

EXPERIMENT : 14
NOISE REMOVAL: ADD NOISE ABOVE 3 KHZ AND THEN REMOVE, INTERFERENCE
SUPPRESSION USING 400 HZ TONE

AIM:

Add the noise above 3 KHz and then remove, interference suppression using 400 Hz tone.

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

ALGORITHM:

1. Get the signal x(n) of length N in matrix form.

2. Add the noise to the signal above 3KHz.

3. Remove the noise from the signal using 400Hz Tone.


4. Draw the Magnitude and Phase spectrum.

THEORY:

In signal processing, noise is a general term for unwanted (and, in general, unknown) modifications
that a signal may suffer during capture, storage, transmission, processing, or conversion.
Noise reduction, the recovery of the original signal from the noise-corrupted one, is a very common
goal in the design of signal processing systems, especially filters. The mathematical limits for noise
removal are set by information theory, namely the Shannon-Nyquist theorem.
In communication systems, noise is an error or undesired random disturbance of a useful
information signal in a communication channel. The noise is a summation of unwanted or disturbing
energy from natural and sometimes man-made sources.

For example in the signal-to-noise ratio (SNR), signal-to-interference ratio (SIR) and signal-to-
noise plus interference ratio (SNIR) measures. Noise is also typically distinguished from distortion, which
is an unwanted systematic alteration of the signal waveform by the communication equipment, for
example in the signal-to-noise and distortion ratio (SINAD). In a carrier-modulated passband analog
communication system, a certain carrier-to-noise ratio (CNR) at the radio receiver input would result in a
certain signal-to-noise ratio in the detected message signal. In a digital communications system, a
certain Eb/N0 (normalized signal-to-noise ratio) would result in a certain bit error rate (BER).

PROGRAM:

clc

clear all

close all

% Noise removal: Add noise above 3KHz and then remove- Interference

% suppression using 400Hz tone


57
DEPARTMENT OF ECE

N=200; f1=100; f2=400; fs=1000;

n=0:N-1;

x=3*sin(2*pi*f1*n/fs)+2*sin(2*pi*f2*n/fs);

L=25; fc=400;

b=fir1(55,fc/fs);

y=filter(b,1,x);

subplot(3,1,1);

plot(n,x,n,y,'r');

title('noise added to the signal');

N=length(x);

Mag_X=2*abs(fft(x))/N;

Mag_X(1)=Mag_X(1)/2;

f_Hz=(1:N/2)*fs/N;

subplot(3,1,2);

plot(f_Hz,Mag_X(1:N/2));

N=length(y);

Mag_Y=2*abs(fft(y))/N;

Mag_Y(1)=Mag_Y(1)/2;

f_Hz=(1:N/2)*fs/N;

subplot(3,1,3)

plot(f_Hz,Mag_Y(1:N/2))

OUTPUT:

58
DEPARTMENT OF ECE

Figure: Noise added to the signal above 3KHz and then removed

RESULT: The noise is added above 3 KHz and then removed using 400 Hz tone.

VIVA QUESTIONS:

1. Define noise and Interference.


2. What is input quantization error?
3. How to generate the 400Hz tone using matlab?
4. What is signal.
5. What is anti aliasing filter.

59
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

% 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];

60
DEPARTMENT OF ECE

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');

OUTPUT

Figure: The impulse response of the sequence

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

61
DEPARTMENT OF ECE

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

62
DEPARTMENT OF ECE

63
DEPARTMENT OF ECE

64

You might also like