DSP LAB MANUAL
DSP LAB MANUAL
Prepared by
Dr. R. Bhargav Ram
Mr B. Venkata Ramana
1
DEPARTMENT OF ECE
LIST OF EXPERIMENTS
2
DEPARTMENT OF ECE
EXPERIMENT 1
GENERATION OF SINUSOIDAL WAVEFORM / SIGNAL BASED ON RECURSIVE
DIFFERENCE EQUATIONS
EQUIPMENTS NEEDED:
Host (PC) with windows (95/98/Me/XP/NT/2000), MATLAB software
ALGORITHM:
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,
3
DEPARTMENT OF ECE
PROGRAM:
clc;
clear all;
close all;
% Signal Frequency and Sampling Frequency
a1=2*cos(f0); a2=-1;
b1=sin(f0);
% Initial values
% output=zeros(1,200);
y1=zeros(1,200);
for i=1:200
ynm2=ynm1;
ynm1=y1(i);
%output(i)=y1(i);
end
subplot(2,1,1)
4
DEPARTMENT OF ECE
plot(1:length(y1),y1);
subplot(2,1,2)
plot(f,Ak(1:(length(y1)+1)/2));
xlabel('Frequency in Hz ')
ylabel('Magnitude in db ');
OUTPUT:
RESULT:
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
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;
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');
plot(y); xlabel('time');
ylabel('amplitude');
OUTPUT:
RESULT:
The histogram of uniformly distributed and white gaussian noise are generated
8
DEPARTMENT OF ECE
Viva Questions
9
DEPARTMENT OF ECE
EXPERIMENT 3
TO FIND DFT / IDFT OF GIVEN DT SIGNAL
EQUIPMENTS REQUIRED:
Host (PC) with windows (95/98/Me/XP/NT/2000), MATLAB software.
ALGORITHM:
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.
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
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');
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');
y=abs(xk);
subplot(2,2,3);
stem(k,y)
11
DEPARTMENT OF ECE
xlabel('-----> k');
z=angle(xk);
subplot(2,2,4);
stem(k,z)
xlabel('-----> k');
OUTPUT:
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');
y=abs(xn);
subplot(2,2,3);
stem(n,y)
xlabel('-----> n');
z=angle(xn);
subplot(2,2,4);
stem(n,z)
xlabel('-----> n');
13
DEPARTMENT OF ECE
OUTPUT:
VIVA QUESTIONS:
14
DEPARTMENT OF ECE
EXPERIMENT 4
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.
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.
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));
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:
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:
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:
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:
% 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)])
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
EQUIPMENTS REQUIRED:
Host (PC) with windows (95/98/Me/XP/NT/2000), matlab software
ALGORITHM:
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
N2 N2 N2
= + = Computations
4 4 2
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
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.
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
24
DEPARTMENT OF ECE
PROGRAM:
%% Clear Section
clear all;
close all;
clc;
Fs = 1000;
T = 1/ Fs;
t = 0:T:1;
plot(y)
z1 = abs(z);
subplot(2,1,1)
plot( N, z1)
z2 = angle (z);
subplot(2,1,2)
plot( N, z2 )
25
DEPARTMENT OF ECE
OUTPUT:
RESULT:
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
EQUIPMENTS REQUIRED:
Host (PC) with windows (95/98/Me/XP/NT/2000), matlab software
ALGORITHM:
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 2ft
S x ( f ) = lim E x(t )e dt
T → 2T
−T
R ( )e
T
− j 2ft
Sx ( f ) = x dt
−T
28
DEPARTMENT OF ECE
Rx ( ) = Ex(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.
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);
rxx= xcorr(x,x);
Sxx=fft(rxx,N);
plot(f,abs(Sxx));
xlabel('frequency f');
ylabel('abs(Sxx)');
30
DEPARTMENT OF ECE
Output:
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
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
VIVA QUESTIONS:
32
DEPARTMENT OF ECE
EXPERIMENT 8
AIM:
Design LP FIR filter and verify with different cutoff frequencies using matlab software.
EQUIPMENTS:
ALGORITHM:
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.
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.
Figure 1 illustrates a low-pass digital filter specification. The word specification actually refers to the
frequency response specification.
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));
ylabel('gain in db-------->');
xlabel('normalized frequency------>');
subplot(2,1,2);
plot(W/pi,angle(H));
ylabel('angle-------->');
xlabel('normalized frequency------>');
OUTPUT:
35
DEPARTMENT OF ECE
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));
ylabel('gain in db-------->');
36
DEPARTMENT OF ECE
xlabel('normalized frequency------>');
subplot(2,1,2);
plot(W/pi,angle(H));
ylabel('angle-------->');
xlabel('normalized frequency------>');
OUTPUT:
RESULT:
37
DEPARTMENT OF ECE
VIVA QUESTIONS:
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
ALGORITHM:
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
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.
40
DEPARTMENT OF ECE
where:
PROGRAM:-
clc;
close all;
clear all;
format long;
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--------->');
subplot(2,1,2);
plot(om/pi,an); grid;
ylabel('phase in db--------->');
INPUT
42
DEPARTMENT OF ECE
OUTPUT
VIVA QUESTIONS:
43
DEPARTMENT OF ECE
EXPERIMENT : 10
EQUIPMENTS NEEDED:
Host (PC) with windows (95/98/Me/XP/NT/2000), matlab software
ALGORITHM:
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:
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
% fs=input('enter the sampling frequency which is greater than twice the signal frequency= ');
b0=0;
b1=sin(f0);
a0=1;
a1=-2*cos(f0);
a2=1;
%% Filtering Operation
y=filter(b,a,x);
subplot(2,1,1)
xlabel('Time in Seconds');
Ak(1)=Ak(1)/2;
45
DEPARTMENT OF ECE
subplot(2,1,2)
xlabel('Frequency in Hz')
OUTPUT
VIVA QUESTIONS:
46
DEPARTMENT OF ECE
EXPERIMENT : 11
EQUIPMENTS NEEDED:
Host (PC) with windows (95/98/Me/XP/NT/2000), matlab software
ALGORITHM:
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.
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
49
DEPARTMENT OF ECE
VIVA QUESTIONS:
50
DEPARTMENT OF ECE
EXPERIMENT : 12
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;
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-->');
subplot(3,1,2);
stem(m);
grid;
xlabel('n-->');
ylabel('Amplitudes of m -->');
subplot(3,1,3);
stem(md);
grid;
xlabel('n/r-->');
ylabel('Amplitude of md-->');
OUTPUT
52
DEPARTMENT OF ECE
VIVA QUESTIONS:
53
DEPARTMENT OF ECE
EXPERIMENT : 13
EQUIPMENTS REQUIRED:
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.
PROGRAM:
clc;
clear all;
close all;
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-->');
subplot(3,1,2);
stem(m);
grid;
xlabel('n-->');
ylabel('Amplitudes of m -->');
subplot(3,1,3);
stem(md);
grid;
xlabel('n x r-->');
ylabel('Amplitude of md-->');
OUTPUT
55
DEPARTMENT OF ECE
VIVA QUESTIONS:
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:
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
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');
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:
59
DEPARTMENT OF ECE
EXPERIMENT : 15
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:
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=[1 1 0.9];
60
DEPARTMENT OF ECE
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');
OUTPUT
RESULT: The impulse response of first order and second order systems are obtained.
61
DEPARTMENT OF ECE
VIVA QUESTIONS:
62
DEPARTMENT OF ECE
63
DEPARTMENT OF ECE
64