DSP Lab Manual New
DSP Lab Manual New
4 DECIMATION 27
5 INTERPOLATION 35
TRANSFORM
LIST OF EXPERIMENTS
AIM: To write and excute MATLAB program for the generation of sinusoidal
wave form
APPARATUS REQUIRED:
Personal Computer
THEORY:
A signal can be defined as a physical quantity, which
ALGORITHM:
1.write a matlab code for generating sinusoidal wave form by using following
parameters
Frequency=1000hz; Vp-p=4V
3. If any errors occur correct those errors and again run the modified matlab file
5. Plot the graph with the help of amplitude values those are obtained at
different time intervals.
PROGRAM:
% SINE WAVE GENERATION
clc; clear all; close all;
t = 0:0.000001:0.001;
f = 1000;
x = 4*sin (2*pi*f*t);
plot(t,x); grid
xlabel('time');
ylabel('amplitude');
title('generation of sinewave');
MODEL GRAPH:
RESULT:
AIM: To write and excute matlab code for the discrete fourier transform of a
given DT signal
APPARATUS REQUIRED:
Personal Computer
ALGORITHM:
3. If any errors occur correct those errors and again run the modified matlab file
5. Plot the graph with the help of amplitude values those are obtained at
PROGRAM :
% DFT
y= fft(x);
subplot(2,1,1);
stem(x);
xlabel('n sequence');
ylabel('amplitude');
title('input sequence');
subplot(2,1,2);
plot(y,'*-');
xlabel('real axis');
ylabel('imaginary axis');
title('input sequence');
y=
Columns 1 through 3
Column 4
-2.0000 - 2.0000i
MODEL GRAPH:
Department of Electronics and Communication Engineering Page 13
Mother Teresa Institute of Science and Technology, Sathupally
RESULT:
KEYPAD STRUCTURE:
1 2 3
100 Hz
4 5 6
200 Hz
7 8 9 300 Hz
* 0 # 400Hz
AIM: To write and excute matlab code for the generation of DTMF signal
APPARATUS REQUIRED:
Personal Computer
MATLAB -7.8 Version(R2009A)
THEORY:
A DTMF Signal consists of the sum of two sinusoids or tones with
frequencies taken from two mutually exclusive groups. These frequencies were
chosen to prevent any harmonics from being incorrectly detected by the receiver
as some other DTMF frequency, each pair of tones contain one frequency from
modern telephony to dial numbers and configure switch boards. It is also used
ALGORITHM:
1. write a matlab code for the DTMF signal generation with the help of low
frequency group,hih frequency group.
Department of Electronics and Communication Engineering Page 18
Mother Teresa Institute of Science and Technology, Sathupally
3. If any errors occur correct those errors and again run the modified matlab fil
5. Plot the graph with the help of amplitude values those are obtained at
different time intervals.
PROGRAM:
% DTMF
symbol = abs(d);
if symbol == 1
f1=100;f2=1100;
end
if symbol == 2
f1=100;f2=1200;
end
if symbol == 3
f1=100;f2=1300;
end
if symbol==4
f1=200;f2=1100;
end
Department of Electronics and Communication Engineering Page 20
Mother Teresa Institute of Science and Technology, Sathupally
if symbol == 5
end
if symbol == 6
f1=200;f2=1300;
end
if symbol == 7
f1=300;f2=1100;
end
if symbol == 8
f1=300;f2=1200;
end
if symbol == 9
f1=300;f2=1300;
end
if symbol == 0
f1=400;f2=1200;
end
if symbol == 35
f1=400;f2=1100;
end
if symbol == 42
f1=400;f2=1300;
Department of Electronics and Communication Engineering Page 22
Mother Teresa Institute of Science and Technology, Sathupally
end
n= 0:100;
x= sin(2*pi*n*f1/8000)+sin(2*pi*f2/8000);
plot(x);
xlabel('nsequence');
ylabel('amplitude');
title('DTMF SIGNAL');
disp(f1);
disp(f2);
OUTPUT:
enter digit=5
200
1200
MODEL GRAPH:
RESULT:
BLOCK DIAGRAM:
fs fs/M
APPARATUS REQUIRED:
Department of Electronics and Communication Engineering Page 26
Mother Teresa Institute of Science and Technology, Sathupally
Personal Computer
MATLAB -7.8 Version(R2009A)
THEORY:
sampling rate of the resulting sequence will be half that of the original
sequence. The problem with dropping samples is that the new sequence may be
violate the sampling thorem,which requires that the sampling frequency must be
greater than two times the highest frequency contents of the signal.
ALGORITHM:
1.Write a matlab program for decimation process.
3.If any errors occur correct those errors and again run the modified matlab file
5. Plot the graph with the help of amplitude values those are obtained at
PROGRAM:
% DECIMATION PROCESS
n = 0 : N-1;
x= sin (2*pi*f1*n);
subplot(2,1,1);
stem(n,x);
xlabel('n sequence');
ylabel('amplitude');
title('input signal');
y= x(1:M:length(x));
subplot(2,1,2);
stem(y);
xlabel('n sequence');
ylabel('amplitude');
title('output signal');
OUTPUT:
MODEL GRAPH:
RESULT:
BLOCK DIAGRAM:
Lfs Lfs
APPARATUS REQUIRED:
Personal Computer
THEORY:
An interpolation filter is used to increase the sampling rate. The
create additional samples to increase the sampling rate for the output..One way
ALGORITHM:
1.Write a matlab program for decimation process.
2. Save and run the corresponding matlab file
3. If any errors occur correct those errors and again run the modified matlab file
PROGRAM:
N = input('enter the length of input signal');
n = 0:N;
x= sin(2*pi*f1*n);
y=zeros(1,L*length(x));
y(1,L:length(y))=x;
plot(n,x,'green*-');hold on;
plot(y);hold off;
xlabel('time');
ylabel('amplitude');
title('INTERPOLATION');
OUTPUT:
RESULT:
APPARATUS REQUIRED:
Personal Computer
MATLAB -7.8 Version(R2009A)
THEORY:
similarity between a signal cross correlation function and time delayed version
density(PSD) .For non periodic signals ESD & ACF forms fourier
parts.
ALGORITHM:
1.write a matlab program for power spectral density of a given signal
Department of Electronics and Communication Engineering Page 40
Mother Teresa Institute of Science and Technology, Sathupally
PROGRAM:
%POWER SPECTRAL DENSITY
t=0:1/fs/1;
pxx1
pxx2
Department of Electronics and Communication Engineering Page 42
Mother Teresa Institute of Science and Technology, Sathupally
subplot (2,1,1);
plot ((0:n1-1)/n1,10*log10(pxx1),'*-');
xlabel ('frequency');
subplot(2,1,2);
plot((0:n2-1)/n2,10*log10(pxx2),'*-');
xlabel('frequency');
OUTPUT:
pxx1 =
pxx2 =
Columns 1 through 6
MODEL GRAPH:
Department of Electronics and Communication Engineering Page 45
Mother Teresa Institute of Science and Technology, Sathupally
RESULT:
APPARATUS REQUIRED:
Personal Computer
band of frequencies of input signal and attenuate all other unwanted frequencies
into 4 types
1.Low pass filter, 2.high pass filter,3.band pass filter,4.band stop filter
ALGORITHM:
1.Write a matlab program for frequency response of a system
PROGRAM:
%FREQUENCY RESPONSE OF A SYSTEM
w = logspace (-1,1);
x=freq z (b,a,w);
mag = abs(10*log10(x));
mag
phase = angle(x);
phase
subplot(2,1,1);
loglog(mag,'*');grid on
xlabel('frequency');
ylabel('magnitude in db’s')
title('magnitude plot');
subplot(2,1,2);
semilogx(phase,'*-');
grid on;
xlabel ('frequency');
ylabel ('phase');
OUTPUT:
phase =
Columns 1 through 6
-0.0168 -0.0185 -0.0204 -0.0224 -0.0247 -0.0272
Columns 7 through 12
-0.0300 -0.0332 -0.0367 -0.0406 -0.0450 -0.0499
Columns 13 through 18
-0.0556 -0.0620 -0.0694 -0.0780 -0.0880 -0.0999
Columns 19 through 24
-0.1141 -0.1312 -0.1523 -0.1783 -0.2111 -0.2524
Columns 25 through 30
-0.3044 -0.3681 -0.4405 -0.5089 -0.5433 -0.4988
Columns 31 through 36
-0.3456 -0.1165 0.1136 0.3154 0.5157 0.7733
Columns 37 through 42
1.1796 -1.3717 -0.8300 -0.4547 -0.0762 0.4659
Columns 43 through 48
0.4073 0.1302 0.0054 -0.1269 -0.5065 0.0902
Columns 49 through 50
0.9637 -0.6396
MODEL GRAPH:
RESULT:
AIM: To write and excute the matlab program for IIR Low pass filetr
APPARATUS REQUIRED:
Personal Computer
THEORY:
IIR filters may be implemented as either analog or digital filters. In digital IIR
filters, the output feedback is immediately apparent in the equations defining the output. Note
that unlike FIR filters, in designing IIR filters it is necessary to carefully consider the "time
zero" case in which the outputs of the filter have not yet been clearly defined as design of
digital IIR filters is heavily dependent on that of their analog counterparts because there are
plenty of resources, works and straightforward design methods concerning analog feedback
filter design while there are hardly any for digital IIR filters. As a result, usually, when a
digital IIR filter is going to be implemented, an analog filter (e.g. Chebyshev filter,
Butterworth filter, Elliptic filter) is first designed and then is converted to a digital filter by
Examples of IIR filters include the Chebyshev filter, Butterworth filter, and the Bessel filter.
ALGORITHM:
1) Enter the pass band ripple (rp) and stop band ripple (rs).
2) Enter the pass band frequency (fp) and stop band frequency (fs).
w1 = 2*fp/f
w2 = 2*fs/f
6)Use an If condition and ask the user to choose either Rectangular Window or
Triangular
m=20*log10(abs(h))
(om/pi)]
10)Give relevant names to x and y axes and give an appropriate title for the plot.
PROGRAM:
% IIR filters
clc;
clear all;
close all;
warning off;
w1=2*wp/fs;w2=2*ws/fs;
w=0:.01:pi;
m=20*log10(abs(h));
subplot(2,1,1);
plot(om/pi,m); grid
ylabel('Gain in dB-->');
an=angle(h);
subplot(2,1,2);
plot(om/pi,an);
ylabel('Phase in radians-->');
OUTPUT:
MODEL GRAPH:
RESULT:
AIM: To write and excute the matlab program for IIR Low pass filetr
APPARATUS REQUIRED:
Personal Computer
THEORY:
Analog prototype filter is a low-pass filter with the cut-off frequency Ωp
= 1. Its transformation to a high-pass analog filter can be split into two steps.
The first step refers to the transformation to a high-pass analog filter, whereas
the second one refers to frequency scaling. The final objective is that passband
ALGORITHM:
1) Enter the pass band ripple (rp) and stop band ripple (rs).
2) Enter the pass band frequency (fp) and stop band frequency (fs).
w1 = 2*fp/f
w2 = 2*fs/f
5) Calculate the order and 3dB cutoff frequency of the analog filter. [Make use
[n,wn]=buttord(w1,w2,rp,rs,.s.)
6) Design an nth order analog high pass Butter worth filter using the following
statement.
[b,a]=butter(n,wn,.high.,.s.)
7) Find the complex frequency response of the filter by using „freqs( ). function
This function returns complex frequency response vector „h. and frequency
m=20*log10(abs(h))
(om/pi)]
11) Plot the phase response [phase in radians Vs normalized frequency (om/pi)]
12) Give relevant names to x and y axes and give an appropriate title for the
plot.
PROGRAM:
% IIR filters
clc;
clear all;
close all;
warning off;
w1=2*wp/fs;w2=2*ws/fs;
w=0:.01:pi;
m=20*log10(abs(h));
subplot(2,1,1);
plot(om/pi,m); grid
ylabel('Gain in dB-->'
an=angle(h);
subplot(2,1,2);
plot(om/pi,an);grid
ylabel('Phase in radians-->');
OUTPUT:
MODEL GRAPH:
RESULT:
Technique.
APPARATUS REQUIRED:
Personal Computer
THEORY:
is a discrete time system that is designed to pass the spectral contents of the
n solutions to design digital filters among them popular approximations are butt
analog filters, and then we can obtain digital filters with the help of transformati
on techniques. There are two types of transformation techniques. Those are imp
ALGORITHM:
1. Write a matlab program for FIR low pass filter by using windowing
technique
PROGRAM:
wc=0.5;
n=24;
w=0:0.01:pi;
h=freqz(b,1,w);
mag=20*log10(abs(h));
plot(w,mag);grid on;
hold on;
w=0:0.01:pi;
h=freqz(b,1,w);
mag=20*log10(abs(h));
plot(w,mag);grid on;
hold off;
xlabel('frequency');
ylabel('magnitude');
MODEL GRAPH:
RESULT:
Technique.
APPARATUS REQUIRED:
Personal Computer
THEORY:
is a discrete time system that is designed to pass the spectral contents of the
first we have to design analog filters, and then we can obtain digital filters with
ALGORITHM:
1.Write a matlab program for FIR high pass filter by using windowing
technique
PROGRAM:
wc=0.5;
n=24;
w=0:0.01:pi;
h=freqz(b,1,w);
mag=20*log10(abs(h));
plot(w,mag);grid on;
hold on;
w=0:0.01:pi;
h=freqz(b,1,w);
MODEL GRAPH:
mag=20*log10(abs(h));
plot(w,mag,'*');grid on;
hold off;
xlabel('frequency');
ylabel('magnitude');
RESULT:
APPARATUS REQUIRED:
Personal Computer
THEORY:
A fast Fourier transform (FFT) is an efficient algorithm to compute the
discrete Fourier transform (DFT) and its inverse. FFTs are of great importance
integers. Evaluating the sums of DFT directly would take O(N 2) arithmetical
operations. An FFT is an algorithm to compute the same result in only O(N log
but there are FFTs with O(N log N) complexity for all N, even for prime
N.Since the inverse DFT is the same as the DFT, but with the opposite sign in
the exponent and a 1/N factor, any FFT algorithm can easily be adapted for it as
well.
ALGORITHM:
1. Write a matlab program for FFT .
PROGRAM:
N=8;
m=8;
n=0:1:N-1;
subplot(2,2,1);
stem(n,a);
ylabel('Amplitude');
title('Sequence');
x=fft(a,m);
k=0:1:N-1;
subplot(2,2,2);
stem(k,abs(x));
ylabel('magnitude');
subplot(2,2,3);
stem(k,angle(x));
ylabel('Phase');
MODEL GRAPH:
RESULT:.