J.N.T.U.H. College of Engineering: Certificate
J.N.T.U.H. College of Engineering: Certificate
J.N.T.U.H. College of Engineering: Certificate
COLLEGE OF ENGINEERING
Certificate
Certified that this is the bonafide record of the practical work done during
the academic year 2017-2018 by
Class IIIrd E.C.E. (Reg) Year 2017-2018 Laboratory Digital Signal Processing
List of Experiments
Class IIIrd E.C.E. (Reg) Year 2017-2018 Laboratory Digital Signal Processing
List of Experiments
Apparatus:
MATLAB (R2008a) software
Theory:
A system is said to be stable if bounded input leads to
inf
if ∑ x[n] < inf
n=−inf
inf
then ∑ y [n] < inf
n=−inf
Procedure:
1. Switch on your computer.
2. Open matlab
3. Open a new editor in file.
4. Write the program.
5. Save it and execute.
Program:
clc
clear all
close all
b=[1 -10 35 -50 24]
a=[1 -1 0.35 0.05 0.0024]
h=filt(b,a)
z=zero(h)
[r p k]=residuez(b,a)
disp(p)
if(max(abs(p))<=1)
disp(‘system is stable’)
Else
disp(‘system is unstable’)
end
zplane(z,p)
Output:
b =1 -10 35 -50 24
h=
1 - 10 z^-1 + 35 z^-2 - 50 z^-3 + 24 z^-4
----------------------------------------------
1 - z^-1 + 0.35 z^-2 + 0.05 z^-3 + 0.0024 z^-4
z=
4.0000
3.0000
2.0000
1.0000
p=
0.5585 + 0.4046i
0.5585 - 0.4046i
-0.0585 + 0.0403i
-0.0585 - 0.0403i
System is stable.
Pole-Zero Plot:
Result:
Signature
2.Frequency Response and Impulse Response
Aim:
To generate a fourth order differential equation and find its frequency response
and impulse response.
Apparatus:
MATLAB (R2008a) software
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 (so LTI), then the frequency response also will
not vary with time. Thus for LTI systems, the frequency response can be seen as
applying the system's transfer function to a purely imaginary number argument
representing the frequency of the sinusoidal excitation.
Procedure:
1. Switch on your computer.
2. Open matlab
3. Open a new editor in file.
4. Write the program.
5. Save it and execute.
Output:
Transfer function:
1
--------------------------------------------
256 - 416 z^-1 + 224 z^-2 - 46 z^-3 + 3 z^-4
Impulse response:
Result:
Hence fourth order differential equation is generated and its frequency
response, impulse response are plotted.
Signature
Apparatus:
MATLAB (R2008a) software
Theory:
In mathematics, the discrete Fourier transform (DFT) converts a finite sequence of
equally-spaced samples of a function into a same-length sequence of equally-spaced
samples of the discrete-time Fourier transform (DTFT), which is a complex-valued
function of frequency. Given a sequence of N samples f (n ), indexed by n =0..N -1, the
Discrete Fourier Transform (DFT) is defined as F (k ), where k =0..N -1:
N −1
F (k) = (1/√N ) * ∑ f (n)e−j2Πkn/N
n=0
The Inverse Discrete Fourier Transform (IDFT):
N −1
f (n) = (1/√N ) ∑ F (k)e+j2Πnk/N
k=0
Procedure:
1. Switch on your computer.
2. Open matlab
3. Open a new editor in file.
4. Write the program.
5. Save it and execute.
Program:[for dft]
clc
clear all
close all
i=input(‘enter the input sequence’)
N=length(i)
for R=1:N
s=0
for n=1:N
s=s+i(n)*exp(-2*pi*j*(n-1)*(R-1)/N)
end
X(R)=s,
End
t=0:N-1
subplot(2,2,1)
plot(t,i)
xlabel(‘time’)
ylabel(‘magnitude’)
title(‘input sequence’)
subplot(2,2,2)
plot(t,abs(X))
xlabel(‘frequency’)
ylabel(‘magnitude’)
title(‘magnitude plot dft’)
subplot(2,2,3)
plot(t,(180/pi)*angle(X))
xlabel(‘frequency’)
ylabel(‘phase’)
title (‘phase plot dft’)
Output:
enter the input sequence[1 2 3 4]
i= 1 2 3 4
N=4
Plot:
Program:[for idft]
clc
clear all
close all
i=input(‘enter the input sequence’)
N=length(i)
for R=1:N
s=0
for n=1:N
s=s+i*exp*(2*pi*j*(n-1)*(R-1)/N)/N
end
X(R)=s
end
Output:
enter the input sequence[2 2+i 2-i 1]
i=
N= 4
X=
Plot:
Result:
Hence, DFT and IDFT of the given sequences are found and plots are plotted.
Signature
Apparatus:
MATLAB (R2008a) software.
Theory:
Convolution is a formal mathematical operation, just as multiplication, addition, and
integration. Addition takes two numbers and produces a third number, while
convolution takes two signals and produces a third signal. Convolution is used in the
mathematics of many fields, such as probability and statistics. In linear systems,
convolution is used to describe the relationship between three signals of interest: the
input signal, the impulse response, and the output signal.The circular convolution, also
known as cyclic convolution, of two aperiodic functions occurs when one of them is
convolved in the normal way with a periodic summation of the other function.
Circular convolution is given by,
∞
x(n) * h(n) = ∑ h[m] ⋅x[n − m]
m=−∞
∞ ∞
= ∑ (h[m] ⋅ ∑ x[n − m − k N ])
m=−∞ k=−∞
Procedure:
1. Switch on your computer.
2. Open matlab
3. Open a new editor in file.
4. Write the program.
5. Save it and execute.
Program:
clc
clear all
close all
x=input('enter 1st sequence')
y=input('enter 2nd sequence')
n1=length(x)
n2=length(y)
if(n1>n2)
y=[y,zeros(n1-n2)]
else
x=[x,zeros(n2-n1)]
end
N=max(n1,n2)
for n=1:N
z(n)=0;
for i=1:N
j=n-i+1;
if(j<0)
j=N+j;
end
z(n)=z(n)+x(i)*y(i)
end
end
Output:
enter sequence 1[1 2 3 4 5]
x =1 2 3 4 5
y= 5 4 3 2 1
n1 = 5
n2 = 5
x= 1 2 3 4 5
N= 5
Z=45 40 40 45 55
Result:
Circular convolution of given two sequences is performed.
Signature
Theory:
DTMF signalling uses two tones to represent each key on the touchpad. There are 12
distinct tones. When any key is pressed the tone of the column and the tone of the row
are generated. As an example, pressing the '5' button generates the tones 770 Hz and
1336 Hz. In this example, use the number 10 to represent the '*' key and 11 to
represent the '#' key.
The frequencies were chosen to avoid harmonics: no frequency is a multiple of another,
the difference between any two frequencies does not equal any of the frequencies, and
the sum of any two frequencies does not equal any of the frequencies.
The frequencies of the tones are as follows:
1209 Hz 1336 Hz 1477 Hz
697 Hz 1 2 3
770 Hz 4 5 6
852 Hz 7 8 9
941 Hz * 0 #
Procedure:
1. Switch on your computer.
2. Open matlab
3. Open a new editor in file.
4. Write the program.
5. Save it and execute.
Program:
clc
clear all
close all
a=[1 2 3;4 5 6; 7 8 9;'*',0,'#']
fs=8000
t=0:1/fs:1
fl=[697 770 852 941]
fh=[1209 1336 1447]
disp('1 2 3')
disp('4 5 6')
disp('7 8 9')
disp('* 0 #')
n=input('enter the key')
for i=1:4
for j=1:3
if(n==a(i,j))
l=fl(i)
h=fh(j)
x1=sin(2*pi*l*t)
x2=sin(2*pi*h*t)
x=x1+x2
end
end
end
subplot(3,1,1)
plot(t,x1)
axis([0 0.1 -2 2])
title('lower frequency signal')
subplot(312)
plot(t,x2)
axis([0 0.1 -2 2])
title('higher frequency signal')
subplot(313)
plot(t,x)
title('final signal')
axis([0 0.1 -2 2])
f=-4000:4000
figure
subplot(311)
plot(f,abs(fft(x1)))
title('low frequency spectrum')
subplot(312)
plot(f,abs(fft(x2)))
title('high frequency spectrum')
subplot(313)
plot(f,abs(fft(x)))
title('dtmf spectrum')
Output:
123
456
789
Enter the key:4
Result:
Hence DTMF signals are generated and corresponding frequency spectrum are
plotted
Signature
6.Overlap Save Method
Aim:
To evaluate the discrete convolution between a very long signal x[n] and a finite
impulse response (FIR) filter h[n].
Apparatus:
MATLAB (R2008a) software.
Theory:
Overlap–save is the traditional name for an efficient way to evaluate the discrete
convolution between a very long signal x[n] and a finite impulse response (FIR) filter
h[n].
∞ M
y k [n] = x[n] * h[n] = ∑ h[m]⋅x[n − m] = ∑ h[m]⋅x[n − m]
m=−∞ m=1
where h[m]=0 for m outside the region [1, M]
The concept is to compute short segments of y[n] of an arbitrary length L, and
concatenate the segments together. Consider a segment that begins at n = kL + M, for
any integer k, and define:
xk [n]⇒x[n + k l] 1≤n≤L + M − 1
⇒0 otherwise
M
y k = xk [n] * h[n] = ∑ h[m]⋅xk [n − m].
m=1
The task is thereby reduced to computing yk[ n], for M ≤ n ≤ L + M − 1.
Now note that if we periodically extend xk[n] with period N ≥ L + M − 1, according to:
∞
xk,N [n] = ∑ xk [n − lN ]
l=−∞
the convolutions (xk,N) *h and xk*h are equivalent in the region M ≤ n ≤ L + M − 1.
So it is sufficient to compute the N-point circular or cyclic convolution of xk[n] with h[n]
in the region [1, N]. The subregion [M, L + M − 1] is appended to the output stream,
and the other values are discarded.
The advantage is that the circular convolution can be computed very efficiently as
follows, according to the circular convolution theorem:
y k [n] = DF T −1 (DF T (xk [n])⋅DF T (h[n]))
Procedure:
1. Switch on your computer.
2. Open matlab
3. Open a new editor in file.
4. Write the program.
5. Save it and execute.
Program:
clc
clearall
closeall
x=input('Enter the sequence x(n)= ');
h=input('Enter the sequence h(n)= ');
l=input('Enter length of each block= ');
subplot(2,2,1)
stem(x)
stem(x,’blue’);
xlabel(‘n’)
ylabel(‘amplitude’)
title(‘x(n)’);
subplot(2,2,2)
stem(h)
stem(h,’black’);
xlabel(‘n’)
ylabel(‘amplitude’);
title(‘H(n)’)
m=length(h)
lx=length(x)
r=rem(lx,L)
x1=[x zeros(1,l-r)];
nr=(length(x1))/l
h1=[h zeros(1,L-1)];
For k=1:nr
ma(k,:)=x1(((k-1)*l+1):k*l)
if k==1
ma1(k,:)=[zeros(1,m-1) ma(k,:)]
else
ma1(k,:)=[ma(k-1,(l-m+2):l) ma(k,:)]
end
ma2(k,:)=ifft(fft(ma1(k,:)).*fft(h1))
end
ma3=ma2(:,m:(l+m-1)
y1=ma3’
y=y1(:)’
subplot(2,2,3:4)
stem(y)
title(‘convoluted signal’)
Output:
Result:
Hence discrete convolution between a signal x[n] and a finite impulse
response (FIR) filter h[n] is determined using overlap save method.
Signature
Theory:
In signal processing the overlap–add method is an efficient way to evaluate the
discrete convolution of a very long signal x[n] with a finite impulse response(FIR) filter
h[n] :
∞ M
y [n] = x[n] * h[n] = ∑ h[m]⋅x[n − m] = ∑ h[m]⋅x[n − m]
m=−∞ m=1
x[n] = ∑ xk [n − k L],
k
= ∑ y k [n − k L]
k
Where y k = xk [n] * h[n] is zero outside the region [1, L + M − 1]. And for any parameter
N>=L+M-1 it is equivalent to the N-point circular convolution of x[n] with h[n] in the
region [1, N].
The advantage is that the circular convolution can be computed very efficiently as
follows, according to the circular convolution theorem:
y k [n] = I DF T (DF T (xk [n])⋅DF T (h[n]))
Procedure:
1. Switch on your computer.
2. Open matlab
3. Open a new editor in file.
4. Write the program.
5. Save it and execute.
Program:
clc
clearall
closeall
x=input('Enter the sequence x(n)= ');
h=input('Enter the sequence h(n)= ');
n1=length(x);
n2=length(h);
N=n1+n2-1;
h1=[h zeros(1,n2-1)];
n3=length(h1);
y=zeros(1,N+n3-n2);
x1=[zeros(1,n3-n2) * zeros(1,n3)];
H=fft(h1);
for i=1:n2:n1
if i<=(n1+n2-1)
x1=[x(i:i+n3-n2) zeros(1,n3-n2)];
else
x1=[x(i:n1) zeros(1,n3-n2)];
end
x2=fft(x1);
x3=x2.*H;
x4=round(ifft(x3))
if(i==1)
y(1:n3)=x4(1:n3);
else
y(i:i+n3-1)=y(i:i+n3-1)+x4(1:n3);
end
end
disp('Output y(n)=');
disp(y(1:N));
stem(y(1:N));
title('overlap add method');
xlabel('n');
ylabel('ý(n)');
Output:
Result:
Hence discrete convolution between a signal x[n] and a finite impulse
response (FIR) filter h[n] is determined using overlap add method.
Signature