Professional Documents
Culture Documents
Signal Processing Lab Manual
Signal Processing Lab Manual
1
GURU NANAK INSTITUTIONS TECHNICAL CAMPUS
Signal Processing lab
1.BasicOperationsonMatrices
2. Generation of Various Signals and Sequences such as unit impulse, unit step,
square,sawtooth,triangular,sinusoidal,ramp,sinc……………………………..
Modified Periodogram
2
GURU NANAK INSTITUTIONS TECHNICAL CAMPUS
Signal Processing lab
Introduction
What Is MATLAB?
MATLAB is a high-performance language for technical computing. It integrates computation,
visualization, and programming in an easy-to-use environment where problems and solutions are
expressed in familiar mathematical notation.
It is one of the leading scientific and technical computing softwares.
The name MATLAB stands for matrix laboratory
In industry, MATLAB is the tool of choice for high-productivity research, development, and
analysis.
As a matrix based system, it is a great tool for simulation and data analysis.
MATLAB is an indispensable Graphical User Interface(GUI) tool and can be used it for proper
understanding of concepts in several prescribed basic and advanced subjects such as
Mathematics
Signals and Systems
Probability Theory and Stochastic Processes
Control Systems
Analog Communications
Digital signal Processing
VLSI Design
Digital Communications
Digital Image Processing
Satellite Communications
Wireless Communications
Embedded Systems
Artificial Neural Networks
3
GURU NANAK INSTITUTIONS TECHNICAL CAMPUS
Signal Processing lab
It provides several optional ‘toolboxes’ such as statistical toolbox, Control systems toolbox,
Neural Networks toolbox, symbolic math tool box, Signal Processing toolbox,etc.,which are
extremely useful for specific applications. Each toolbox provides a set of functions written for a
specific application
Starting MATLAB
To start MATLAB, double-click the MATLAB shortcut icon on your Windows desktop.
MATLAB Desktop
When you start MATLAB, the MATLAB desktop appears, containing tools (graphical user
interfaces) for managing files, variables, and applications associated with MATLAB.
4
GURU NANAK INSTITUTIONS TECHNICAL CAMPUS
Signal Processing lab
5
GURU NANAK INSTITUTIONS TECHNICAL CAMPUS
Signal Processing lab
EXPERIMENT 1
Variables
>>x=3+4
Creates a variable and assigns a value 7 to it
Expressions and Statements
Matlab can be used as a simple calculator
>>34/7
>>log(12)
>>y=sqrt(17)
>>a=3+ 4*j
>>b=abs(a)
Entering Matrices
•Separate the elements of a row with blanks or commas.
•Use a semicolon, ; , to indicate the end of each row.
•Surround the entire list of elements with square brackets, [ ].
To enter a matrix, simply type in the Command Window
A = [16 3 2 13; 5 10 11 8; 9 6 7 12; 4 15 14 1]
MATLAB displays the matrix you just entered.
A=
16 3 2 13
5 10 11 8
9 6 7 12
4 15 14 1
6
GURU NANAK INSTITUTIONS TECHNICAL CAMPUS
Signal Processing lab
MATLAB replies with
ans =
34 34 34 34
>>A’
ans =
16 5 9 4
3 10 6 15
2 11 7 14
13 8 12 1
And
>>sum(A')'
produces a column vector containing the row sums
ans =
34
34
34
34
The sum of the elements on the main diagonal is easily obtained with the help
of the diag function, which picks off that diagonal.
>>diag(A)
produces
ans =
16
10
7
1
and
sum(diag(A))
produces
ans =
34
7
GURU NANAK INSTITUTIONS TECHNICAL CAMPUS
Signal Processing lab
>>diag(A)
Subscripts
The element in row i and column j of A is denoted by A(i,j). For example,
A(4,2) is the number in the fourth row and second column.
The Colon Operator
The colon, :, is one of MATLAB’s most important operators. It occurs in several
different forms. The expression
1:10
is a row vector containing the integers from 1 to 10
1 2 3 4 5 6 7 8 9 10
Operations on Vectors
Let a=[5 2 1 4 3] , b=[ 8 6 7]
8
GURU NANAK INSTITUTIONS TECHNICAL CAMPUS
Signal Processing lab
B=
16 2 3 13
5 11 10 8
9 7 6 12
4 14 15 1
Arithmetic and Relational Operators
Arithmetic
Operator Operation
+ Addition
- Subtraction
* Matrix Multiplication
.* Array Multiplication
/ Division
^ Matrix Power
.^ Array Power
' Transpose
== Equal
~= Not Equal
< Less Than
<= Less Than or Equal
> Greater Than
>= Greater Than or Equal
9
GURU NANAK INSTITUTIONS TECHNICAL CAMPUS
Signal Processing lab
Matrix Functions
10
GURU NANAK INSTITUTIONS TECHNICAL CAMPUS
Signal Processing lab
\
EXPERIMENT 2
Program:
t = 0 : 0.001 : 1;
y = 0.5 * t;
plot( t , y );
xlabel ('Time Index t (sec.)');
ylabel ('Amplitude');
title ('Ramp Signal Sequence');
11
GURU NANAK INSTITUTIONS TECHNICAL CAMPUS
Signal Processing lab
Expected Graph:
0.45
0.4
0.35
0.3
Amplitude
0.25
0.2
0.15
0.1
0.05
0
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Time Index t (sec.)
Result:
12
GURU NANAK INSTITUTIONS TECHNICAL CAMPUS
Signal Processing lab
2(b) Sawtooth signal
Aim:
To generate sawtooth wave signal.
Software used:
1. Operating system-Windows XP
2. Matlab R2009b
Theory:
Repeating waveform that rises from zero to maximum value linearly drops back to zero and
repeats.
Program:
fs = 10000;
t = 0 : 1/fs : 1.5;
x = sawtooth (2 * pi * 100 * t);
plot( t , x ); axis ( [ 0 0.05 -1 1 ] );
xlabel('Time Index t (sec.)');
ylabel('Amplitude');
title ('Sawtooth Wave Signal Sequence');
Expected Graph
0.8
0.6
0.4
0.2
Amplitude
-0.2
-0.4
-0.6
-0.8
-1
0 0.005 0.01 0.015 0.02 0.025 0.03 0.035 0.04 0.045 0.05
Time Index t (sec.)
Result: .
13
GURU NANAK INSTITUTIONS TECHNICAL CAMPUS
Signal Processing lab
EXPERIMENT-2(c)
Aim:
To generate sync signal
Software used:
1. Operating system-Windows XP
2. Matlab R2009b
Theory:
There is a particular form that appears so frequently in communications engineering, that we
give it its own name. This function is called the "Sinc function" and is discussed below: The Sinc
function is defined in the following manner:
Here we are using the stylized "L" over the thick arrow to denote L'Hopital decomposition. Since
cos(0) = 1, we can show that at x = 0, the sinc function value is equal to 1. Also, the Sinc
function approaches zero as x goes towards infinity. The envelope of sinc(x) tapers off as 1/x.
14
GURU NANAK INSTITUTIONS TECHNICAL CAMPUS
Signal Processing lab
Program:
t = linspace(-5 , 5);
y = sinc(t);
plot(t , y);
xlabel('Time Index t (sec.)');
ylabel('Amplitude');
title('Sinc Signal Sequence');
Expected Graph:
0.8
0.6
0.4
Amplitude
0.2
-0.2
-0.4
-5 -4 -3 -2 -1 0 1 2 3 4 5
Time Index t (sec.)
Result:
15
GURU NANAK INSTITUTIONS TECHNICAL CAMPUS
Signal Processing lab
EXPERIMENT-2(d)
Aim:
To generate a sinusoidal signal
Software used:
1. Operating system-Windows XP
2. Matlab R2009b
Theory:
The sine wave or sinusoid is a mathematical function that describes a smooth repetitive
oscillation. It occurs often in pure mathematics, as well as physics, signal processing, electrical
engineering and many other fields. Its most basic form as a function of time (t) is:
Where,
A, the amplitude, is the peak deviation of the function from its center position.
ω, the angular frequency, specifies how many oscillations occur in a unit time interval, in
radians per second
When the phase is non-zero, the entire waveform appears to be shifted in time by the
amount φ/ω seconds. A negative value represents a delay, and a positive value represents
a "head-start".
16
GURU NANAK INSTITUTIONS TECHNICAL CAMPUS
Signal Processing lab
Program:
N=20;
t = -N : .0001 : N;
theta = input('The phase angle is ');
x = sin (2 * pi * 50 * t + theta);
plot( t , x ); axis( [-.04 .04 -1 1] );
grid;
xlabel ('Time Index t (sec.)');
ylabel ('Amplitude');
title ('Sinusoidal Signal of Frequency 50 Hz and Desired Phase').
Expected Graph:
Result:.
17
GURU NANAK INSTITUTIONS TECHNICAL CAMPUS
Signal Processing lab
EXPERIMENT-2(e)
Aim:
To generate a square wave signal
Software used:
1. Operating system-Windows XP
2. Matlab R2009b
Program:
t = 0 : 0.0001 : 0.1;
y = square ( 2 * pi * 50 * t);
plot(t , y); axis ( [ 0 0.1 -2 2 ] );
xlabel('Time Index t (sec.)');
ylabel('Amplitude');
title('Square Wave Signal Sequence');
Expected Graph:
Square Wave Signal Sequence
2
1.5
0.5
Amplitude
-0.5
-1
-1.5
-2
0 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1
Time Index t (sec.)
Result:
18
GURU NANAK INSTITUTIONS TECHNICAL CAMPUS
Signal Processing lab
EXPERIMENT-2(f)
Aim:
To generate a triangular wave signal
Software used:
1. Operating system-Windows XP
2. Matlab R2009b
Program:
fs = 10000;
t = 0 : 1/fs : 1.5;
x = sawtooth (2 * pi * 50 * t , 0.5);
plot(t,x); axis ( [ 0 0.1 -1 1 ] );
xlabel('Time Index t (sec.)');
ylabel('Amplitude');
title('Triangular Wave Signal Sequence');
Expected Graph:
0.8
0.6
0.4
0.2
Amplitude
-0.2
-0.4
-0.6
-0.8
-1
0 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1
Time Index t (sec.)
Result:
19
GURU NANAK INSTITUTIONS TECHNICAL CAMPUS
Signal Processing lab
EXPERIMENT-2(g)
Aim:
To generate a unit impulse signal
Software used:
1. Operating system-Windows XP
2. Matlab R2009b
Program:
clc;
clear all;
m1 = input(' Please input a NEGATIVE number for “m1” ');
m2 = input(' Please input a POSITIVE number for “m2” ');
m = [m1 : m2];
x = zeros(1,m2-m1+1);
m0 = input(' Type 0 for Unit Impulse, negative/ positive no. for delayed/ advanced signal');
x(m0-m1+1) = 1;
stem( m , x ); axis( [ m1 m2 -1.5 1.5 ] );
xlabel('Time Index m (sec.)');
ylabel('Amplitude');
title('Unit Impulse Signal Sequence');
20
GURU NANAK INSTITUTIONS TECHNICAL CAMPUS
Signal Processing lab
Expected Graph:
Result:
21
GURU NANAK INSTITUTIONS TECHNICAL CAMPUS
Signal Processing lab
EXPERIMENT-2(h)
Aim:
To generate a unit step signal
Software used:
1. Operating system-Windows XP
2. Matlab R2009b
Program:
clc; clear all;
k1 = input('Please input a NEGATIVE number for “k1” ');
k2 = input('Please input a POSITIVE number for “k2” ');
k0 = input('Type 0 for normal Unit Step, a negative or positive no. for a shifted one ');
k = [k1 : k2];
x = zeros(1,k2-k1+1);
x( k0-k1+1 : end ) = 1;
stem( k , x );
axis( [ k1 k2 -1.5 1.5 ] );
xlabel('Time Index k (sec.)');
ylabel('Amplitude');
title('Unit Step Signal Sequence');
22
GURU NANAK INSTITUTIONS TECHNICAL CAMPUS
Signal Processing lab
Expected Graph:
Result:
23
GURU NANAK INSTITUTIONS TECHNICAL CAMPUS
Signal Processing lab
EXPERIMENT-3
Aim: -
To write a MATLAB program for various basic operations on given sequences
Software used: -
MATLAB 7.5
Program: -
%% Clearing and closing commands
clc
clear all
close all
%% Declaring Input sequences
x=[1:1:8];
y=[8:-1:1];
%% Plotting the results of different operations
% Input sequence 1
subplot(3,2,1)
stem(x)
xlabel('no of samples')
ylabel('amplitude')
title('input sequence 1')
% Input sequence 2
subplot(3,2,2)
stem(y)
xlabel('no of samples')
ylabel('amplitude')
title('input sequence 2')
% Addition of sequences
24
GURU NANAK INSTITUTIONS TECHNICAL CAMPUS
Signal Processing lab
m=x+y;
subplot(3,2,3)
stem(m)
xlabel('no of samples')
ylabel('amplitude')
title('addition of signals')
% Multiplication of sequences
m=x.*y;
subplot(3,2,4)
stem(m)
xlabel('no of samples')
ylabel('amplitude')
title('multipilcation of signals')
% Folding of sequences
subplot(3,2,5)
stem(-x,x)
xlabel('no of samples')
ylabel('amplitude')
title('folded sequence')
% Amplitude scaling
subplot(3,2,6)
stem(x,x*2)
xlabel('no of samples')
ylabel('amplitude')
title('amplitude Scaling')
Result: -Hence basic operations signals have been generated and plotted using MATLAB
25
GURU NANAK INSTITUTIONS TECHNICAL CAMPUS
Signal Processing lab
Output:
26
GURU NANAK INSTITUTIONS TECHNICAL CAMPUS
Signal Processing lab
EXPERIMENT-4
Aim: -
To write a MATLAB program to verify INTERPOLATION and DECIMATION of a given
sequence.
Software used:
-MATLAB 7.5
Program: -
%% Clearing and Closing commands
clc
clear all
close all
%% Program for Interpolation
t=0:0.05:2;
x=cos(2*pi*t);
y=interp(x,2);
t2=interp(t,2);
subplot(2,1,1)
stem(t,x)
xlabel('Number of Namples');
ylabel('Amplitude')
title('Input Sequence')
subplot(2,1,2)
stem(t2,y)
xlabel('Number of Samples');
ylabel('Amplitude')
27
GURU NANAK INSTITUTIONS TECHNICAL CAMPUS
Signal Processing lab
title('Interpolated Sequence')
%% Program for Decimation
t=0:0.05:2;
x=cos(2*pi*t);
y=decimate(x,2);
t1=decimate(t,2);
subplot(2,1,1)
stem(t,x)
xlabel('Number of Samples');
ylabel('Amplitude')
title('Input Sequence')
subplot(2,1,2)
stem(t1,y)
xlabel('Number of Samples');
ylabel('Amplitude')
title('Decimated Sequence')
Result: - Hence the INTERPOLATION and DECIMATION of a given sequence has been
verified using MATLAB
Output:
28
GURU NANAK INSTITUTIONS TECHNICAL CAMPUS
Signal Processing lab
29
GURU NANAK INSTITUTIONS TECHNICAL CAMPUS
Signal Processing lab
30
GURU NANAK INSTITUTIONS TECHNICAL CAMPUS
Signal Processing lab
EXPERIMENT-5
Aim:
To write a MATLAB program to convert CD data to DVD data
Software used:
MATLAB 7.5
Program: -
%% Clearing and closing commands
clc
clear all
close all
%% Program
[y, Fs, nbits] = wavread('type.wav');
disp('The sampling frequency is:');
Fs
disp('Number of bits per sample:');
nbits
disp('The length of the CD data is:');
length(y)
%%
p=interp(y,2);
Fs1=Fs*2;
disp('The sampling frequency is:');
Fs1
disp('Number of bits per sample:');
nbits
disp('The length of the DVD data is:');
length(p)
31
GURU NANAK INSTITUTIONS TECHNICAL CAMPUS
Signal Processing lab
wavplay(y,Fs);
pause(2);
wavplay(p,Fs1);
Result:-Hence the data sampled at CD sampling rate is converted into DVD sampling rate has
been verified using MATLAB
Outputs: -
The sampling frequency is:
Fs =
11025
nbits =
ans =
4409
Fs1 =
22050
32
GURU NANAK INSTITUTIONS TECHNICAL CAMPUS
Signal Processing lab
nbits =
ans =
8818
33
GURU NANAK INSTITUTIONS TECHNICAL CAMPUS
Signal Processing lab
EXPERIMENT-6
Aim:
To write a MATLAB program to estimate power spectrum using BARTLETT and
WELCH method.
Software used:
MATLAB 7.5
Program: -
%% Clearing and Closing commands
clc
clear all
close all
%% Declaring Inputs
fs=2000;
f1=200;
f2=400;
M=128;
Program for BARTLETT METHOD:
t=0:1/fs:1;
x=2*sin(2*pi*f1*t)+2*sin(2*pi*f2*t)+rand(size(t));
L=length(x);
K=L/M;
y1=[];
for i=1:M:L-M
y2=abs(fft(x(i:i+M)).^2);
y1=[y1;y2];
end
y3=sum(y1);
34
GURU NANAK INSTITUTIONS TECHNICAL CAMPUS
Signal Processing lab
w1=y3/K;
w12=10*log(w1);
fs1=(fs/K)+2;
t1=((1:fs1)/fs1);
plot(t1,w12)
xlabel('Normalized Frequency')
ylabel('PSD')
title('BARTLETT METHOD of Power Spectral Estimation');
Program for WELCH METHOD:
t=0:1/fs:1;
x=2*sin(2*pi*f1*t)+2*sin(2*pi*f2*t)+rand(size(t));
L=length(x);
K=L/M;
w=hann(M+1);
m=0;
su=[];
for i=1:M/2:L-M+1
g=w'.*x(i:M+i);
w2=abs(fft(g).^2);
su=[su;w2];
end
su1=sum(su);
f=sum(w.^2);
w1=su1/f;
w12=10*log(w1);
fs1=(fs/K)+2;
t1=((1:fs1)/fs1);
plot(t1,w12)
xlabel('Normalized Frequency')
ylabel('PSD')
title('WELCH METHOD of Power Spectral Estimation');
35
GURU NANAK INSTITUTIONS TECHNICAL CAMPUS
Signal Processing lab
Result: -Hence the estimation of PSD using BARTLETT and WELCH method has been verified
using MATLAB
36
GURU NANAK INSTITUTIONS TECHNICAL CAMPUS
Signal Processing lab
Welch Method
37
GURU NANAK INSTITUTIONS TECHNICAL CAMPUS
Signal Processing lab
EXPERIMENT-7
38
GURU NANAK INSTITUTIONS TECHNICAL CAMPUS
Signal Processing lab
Result: -Hence the estimation of PSD using BLACKMAN-TUKEY method has been verified
using MATLAB.
Output: -
39
GURU NANAK INSTITUTIONS TECHNICAL CAMPUS
Signal Processing lab
EXPERIMENT-8
ESTIMATION OF POWER SPECTRUM USING PARAMETRIC METHODS
(YULE-WALKER & BURG)
Aim:-
To write a MATLAB program to estimate power spectrum using Power Spectrum using
YULE-WALKER and BURG method.
Software used: -
MATLAB 7.5
Program:
%% Clearing and Closing commands
clc
clear all
close all
Program for BURG method:
a=[1 -2.2137 2.9408 -2.1697 0.9609];
randn('state',1);
x=filter(1,a,randn(256,1));
pburg(x,4);
xlabel('Normalized Frequency');
ylabel('Power Sectrum in db');
title('BURG method of Power Spectrum Estimation');
Program for YULE WALKER method:
a=[1 -2.2137 2.9408 -2.1697 0.9609];
randn('state',1);
x=filter(1,a,randn(256,1));
pyulear(x,4);
xlabel('Normalized Frequency');
ylabel('Power Spectrum in db');
title('YULE-WALKER method of Power Spectrum Estimation');
40
GURU NANAK INSTITUTIONS TECHNICAL CAMPUS
Signal Processing lab
Result: -Hence the estimation of PSD using YULE-WALKER and BURG method has been
verified using MATLAB
41
GURU NANAK INSTITUTIONS TECHNICAL CAMPUS
Signal Processing lab
EXPERIMENT-9
Result: -Hence the Design of LPC filter using LEVINSON-DURBIN Algorithm has been
verified using MATLAB
42
GURU NANAK INSTITUTIONS TECHNICAL CAMPUS
Signal Processing lab
Output: -
43
GURU NANAK INSTITUTIONS TECHNICAL CAMPUS
Signal Processing lab
EXPERIMENT-10
Aim: -
To write a MATLAB program to generate various fundamental Signals.
Software used: -
MATLAB 7.5
Program:-
%% Clearing and closing commands
clc
clear all
close all
%% Plotting Various Signals
% program for unit step sequence
n=-5:1:5;
y1=[zeros(1,5) 1 ones(1,5)];
subplot(4,2,1)
stem(n,y1)
xlabel('no of samples');
ylabel('amplitude');
title('unit step sequence');
% program for impulse sequence
n=-5:1:5;
y2=[zeros(1,5) 1 zeros(1,5)];
subplot(4,2,2)
stem(n,y2)
xlabel('no of samples');
ylabel('amplitude');
title('impulse sequence')
% program for ramp sequence
44
GURU NANAK INSTITUTIONS TECHNICAL CAMPUS
Signal Processing lab
m=0:1:5;
y3=m;
subplot(4,2,3)
stem(m,y3)
xlabel('no of samples')
ylabel('amplitude')
title('ramp sequence')
% program for exponentially increasing
t=0:1:5;
a1=.5;
y4=exp(a1*t);
subplot(4,2,4)
stem(t,y4)
xlabel('no of samples')
ylabel('amplitude')
title('exponential increasing sequence')
% program for exponentially decreasing
t=0:1:5;
a2=.2;
y5=exp(-a2*t);
subplot(4,2,5)
stem(t,y5)
xlabel('no of samples')
ylabel('amplitude')
title('exponential decreasing sequence')
% program for sine wave generation
t=0:0.1:2;
y6=sin(2*pi*t);
subplot(4,2,6)
stem(t,y6)
xlabel('no of samples')
45
GURU NANAK INSTITUTIONS TECHNICAL CAMPUS
Signal Processing lab
ylabel('amplitude')
title('sine wave')
% program for cosine wave generation
t=0:0.1:2;
y7=cos(2*pi*t);
subplot(4,2,7)
stem(t,y7)
xlabel('no of samples')
ylabel('amplitude')
title('cosine wave')
Result: - Hence different basic signals have been generated and plotted using MATLAB
Output: -
46
GURU NANAK INSTITUTIONS TECHNICAL CAMPUS
Signal Processing lab
EXPERIMENT-11
47
GURU NANAK INSTITUTIONS TECHNICAL CAMPUS
Signal Processing lab
xlabel('Frequency in Hertz:')
ylabel('Power in db:')
title('PSD using AUTOCORRELATION METHOD')
48
GURU NANAK INSTITUTIONS TECHNICAL CAMPUS
Signal Processing lab
Outputs: - Periodogram
Modified Periodogram
49
GURU NANAK INSTITUTIONS TECHNICAL CAMPUS
Signal Processing lab
EXPERIMENT-12
Aim: -
To write a MATLAB program for generation of DTMF signals
Software used: -
MATLAB 7.5
Program: -
%% Clearing and closing commands
clc
clear all
close all
%% Program
number=['9177857260','s'];
fs=8192;
T=0.5;
x=2*pi*[697,770,852,941];
y=2*pi*[1209,1336,1477];
t=[0:1/fs:T]';
tx=[sin(x(1)*t),sin(x(2)*t),sin(x(3)*t),sin(x(4)*t)]/2;
ty=[sin(y(1)*t),sin(y(2)*t),sin(y(3)*t)]/2;
for k=1:length(number)
switch number(k)
case'1'
tone=tx(:,1)+ty(:,1);
% sound(tone);
stem(tone);
50
GURU NANAK INSTITUTIONS TECHNICAL CAMPUS
Signal Processing lab
xlabel('No of Samples');
ylabel('Amplitude');
title('Dual Tone Multiple Frequency');
case'2'
tone=tx(:,1)+ty(:,2);
% sound(tone);
stem(tone);
xlabel('No of Samples');
ylabel('Amplitude');
title('Dual Tone Multiple Frequency');
case'3'
tone=tx(:,1)+ty(:,3);
% sound(tone);
stem(tone);
xlabel('No of Samples');
ylabel('Amplitude');
title('Dual Tone Multiple Frequency');
case'4'
tone=tx(:,2)+ty(:,1);
% sound(tone);
stem(tone);
xlabel('No of Samples');
ylabel('Amplitude');
title('Dual Tone Multiple Frequency');
case'5'
tone=tx(:,2)+ty(:,2);
% sound(tone);
51
GURU NANAK INSTITUTIONS TECHNICAL CAMPUS
Signal Processing lab
stem(tone);
xlabel('No of Samples');
ylabel('Amplitude');
title('Dual Tone Multiple Frequency');
case'6'
tone=tx(:,2)+ty(:,3);
% sound(tone);
stem(tone);
xlabel('No of Samples');
ylabel('Amplitude');
title('Dual Tone Multiple Frequency');
case'7'
tone=tx(:,3)+ty(:,1);
% sound(tone);
stem(tone);
xlabel('No of Samples');
ylabel('Amplitude');
title('Dual Tone Multiple Frequency');
case'8'
tone=tx(:,3)+ty(:,2);
% sound(tone);
stem(tone);
xlabel('No of Samples');
ylabel('Amplitude');
title('Dual Tone Multiple Frequency');
case'9'
tone=tx(:,3)+ty(:,3);
52
GURU NANAK INSTITUTIONS TECHNICAL CAMPUS
Signal Processing lab
% sound(tone);
stem(tone);
xlabel('No of Samples');
ylabel('Amplitude');
title('Dual Tone Multiple Frequency');
case'*'
tone=tx(:,4)+ty(:,1);
% sound(tone);
stem(tone);
xlabel('No of Samples');
ylabel('Amplitude');
title('Dual Tone Multiple Frequency');
case'0'
tone=tx(:,4)+ty(:,2);
% sound(tone);
stem(tone);
xlabel('No of Samples');
ylabel('Amplitude');
title('Dual Tone Multiple Frequency');
case'#'
tone=tx(:,4)+ty(:,3);
% sound(tone);
stem(tone);
xlabel('No of Samples');
ylabel('Amplitude');
title('Dual Tone Multiple Frequency');
% otherwise
53
GURU NANAK INSTITUTIONS TECHNICAL CAMPUS
Signal Processing lab
% disp('invalid number');
end;
pause(0.75);
end;
Result: -Hence the above DTMF signals has been generated and plotted using MATLAB
Output:
54
GURU NANAK INSTITUTIONS TECHNICAL CAMPUS
Signal Processing lab
EXPERIMENT-13
Aim: -
To write a MATLAB program to find out the DFT & IDFT of a given sequence.
Software used: -
MATLAB 7.5
Program: -
%% Clearing and closing commands
clc
clear all
close all
%% Program for DFT
N=8;
x=[1 2 3 4 4 3 2 1];
for k=0:1:N-1;
for n=0:1:N-1;
p=exp(-j*2*pi*n*k/N);
x2(k+1,n+1)=p;
end;
end;
y=x*x2;
disp(y);
stem(x,y);
xlabel('time period')
ylabel('amplitude');
title('DFT of the sequence');
55
GURU NANAK INSTITUTIONS TECHNICAL CAMPUS
Signal Processing lab
x=[1 2 3 4 4 3 2 1];
for k=0:1:N-1;
for n=0:1:N-1;
p=exp(j*2*pi*n*k/N);
x1(k+1,n+1)=p;
end;
end;
y=(x*x1)/N;
disp(y);
stem(x,y);
xlabel('time period');
ylabel('amplitude');
title('IDFT of the sequence');
56
GURU NANAK INSTITUTIONS TECHNICAL CAMPUS
Signal Processing lab
Result: - Hence the DFT & IDFT of the given sequence has been found and plotted using
MATLAB
Outputs: -
FFT
Columns 1 through 4
Columns 5 through 8
57
GURU NANAK INSTITUTIONS TECHNICAL CAMPUS
Signal Processing lab
IFFT
Columns 1 through 4
2.5000 -0.7286 + 0.3018i 0.0000 + 0.0000i -0.0214 + 0.0518i
Columns 5 through 8
0 + 0.0000i -0.0214 - 0.0518i -0.0000 + 0.0000i -0.7286 - 0.3018i
58