Академический Документы
Профессиональный Документы
Культура Документы
DIGITAL SIGNAL PROCESSING LAB LIST OF EXPERIMENTS: Program implementation using Software MATLAB 1) 2) 3) 4) Generation of Standard Waveforms/ Signals. Implementation of FFT of a given Signal Impulse response of I & II order Systems To find Frequency response of a given System given in (Transfer Function/Differential equation form) 5) To find DFT/IDFT of given DT signal 6) Determination of Power Spectrum of a given signals 7) Implementation of LP FIR filter for a given sequences 8) Implementation of HP FIR filter for a given sequences 9) Implementation of LP IIR filter for a given sequences a) Using Butterworth Filter b) Using Chebyshev Filter 10) Implementation of HP FIR filter for a given sequences a) Using Butterworth Filter b) Using Chebyshev Filter 11) Implementation of Decimation Process 12) Implementation of Interpolation Process 13) Generation of DTMF signals
LIST OF EXPERIMENTS According to JNTU SYLLABUS: SIMULATION LAB S.No 1 2 3 4 Experiment Name Generation of Standard Waveforms/ Signals Implementation of FFT of a given Signal Impulse response of I & II order Systems To find Frequency response of a given System given in (Transfer Function/Differential equation form) To find DFT/IDFT of given DT signal Determination of Power Spectrum of a given signals Implementation of LP FIR filter for a given sequences Implementation of HP FIR filter for a given sequences Implementation of LP IIR filter for a given sequences a) Using Butterworth Filter b) Using Chebyshev Filter Implementation of HP FIR filter for a given sequences c) Using Butterworth Filter d) Using Chebyshev Filter Implementation of Decimation Process Implementation of Interpolation Process Generation of DTMF signals Pg.No
5 6 7 8 9
10
11 12 13
PROGRAM:
clc; clear all; n=0:0.5:2*pi; y=sin(n); stem(n,y); xlabel('time period'); ylabel('magnitude'); title('sinusoidal wave');
Output Waveform:
sinusoidal wave 1 0.8 0.6 0.4 0.2 magnitude 0 -0.2 -0.4 -0.6 -0.8 -1
a) Sine Wave:
3 time period
b) Cosine wave
clc; clear all; n=0:0.5:2*pi; y=cos(n); stem(n,y); xlabel('time period'); ylabel('magnitude'); title('cosine wave');
Output Waveform:
sine wave with 50hz 1 0.8 0.6 0.4 0.2 amplitude 0 -0.2 -0.4 -0.6 -0.8 -1
3 4 time period
c) Unit Step
Output Waveform:
unit step signal 1 0.9 0.8 0.7 0.6 magnitude 0.5 0.4 0.3 0.2 0.1 0
0.5
1.5
3.5
4.5
d) Unit Impulse
clc; clear all; t=0:0.2:2*pi; y=[ones(1,1),zeros(1,2*pi)]; stem(y); xlabel('time period'); ylabel('amplitude'); title('UNIT impulse signal');
Output Waveform:
UNIT impulse signal 1 0.9 0.8 0.7 0.6 amplitude 0.5 0.4 0.3 0.2 0.1 0
4 time period
Result: Hence we generated the waveform of sine wave, cosine wave, unit step wave, unit impulse wave signals.
AIM: To write a program to find FFT of given sequence SOFTWARE USED: MATLAB7.1 PROGRAM:
% FFT of given sequence % clc; clear all; x=input('enter input sequence a(n)'); n=length(x); y=fft(x,n); m=abs(y); subplot(1,2,1); stem(m); xlabel('time'); ylabel('magnitude'); p=angle(y); subplot(1,2,2); stem(p); xlabel('time'); ylabel('phase in radians'); title('phase plot');
INPUT:
magnitude
-1
-2
-3
2 time
%Impulse Response Ist order% clc; clear all; n=0:1:20; x=[1,zeros(1,20)] b=input('enter the num coefficient'); a=input('enter the den coefficient'); y=filter(b,a,x); subplot(2,1,1); stem(n,x); xlabel('n'); ylabel('input sequence x(n)'); subplot(2,1,2); stem(n,y); xlabel('n'); ylabel('impulse response');
INPUT VALUES: Enter the num coefficient for I order [1]; Enter the den coefficient for I order [1,-0.08];
DIGITAL SIGNAL PROCESSING LAB OUTPUT WAVE FORM FOR I st ORDER IMPULSE RESPONSE:
10
0.5
10 n
12
14
16
18
20
1 impulse response
0.5
10 n
12
14
16
18
20
PROGRAM :
%Impulse Response of II order% clc; clear all; n=0:1:20; x=[1,zeros(1,20)] b=input('enter the num coefficient'); a=input('enter the den coefficient'); y=filter(b,a,x); subplot(2,1,1); stem(n,x); xlabel('n'); ylabel('input sequence x(n)'); subplot(2,1,2); stem(n,y); xlabel('n'); ylabel('impulse response');
DIGITAL SIGNAL PROCESSING LAB INPUT VALUES: Enter the num coefficient for II order [1]; Enter the den coefficient for II order [1,-0.6,0.08];
11
0.5
10 n
12
14
16
18
20
1 impulse response
0.5
-0.5
10 n
12
14
16
18
20
Systems
12
%Frequency Response of I order% clc; clear all; b=input('enter the num coff'); a=input('enter the den coff'); w=0:0.01:pi; h=freqz(b,a,w); subplot(2,1,1); plot(w/pi,abs(h)); xlabel('normalised freq'); ylabel('magnitude'); grid; subplot(2,1,2); plot(w/pi,angle(h)); xlabel('normalised freq'); ylabel('phase in radus'); grid;
INPUT VALUES: Enter the num coefficient [1]; Enter the den coefficient [1,-0.08];
13
1.2
magnitude
1.1
0.9
0.1
0.2
0.3
0.7
0.8
0.9
0 phase in radus
-0.05
-0.1
0.1
0.2
0.3
0.7
0.8
0.9
PROGRAM:
%Frequency Response of II order% clc; clear all; b=input('enter the num coff'); a=input('enter the den coff'); w=0:0.01:pi; h=freqz(b,a,w); subplot(2,1,1); plot(w/pi,abs(h)); xlabel('normalised freq'); ylabel('magnitude'); grid; subplot(2,1,2); plot(w/pi,angle(h)); xlabel('normalised freq'); ylabel('phase in radus'); grid;
DIGITAL SIGNAL PROCESSING LAB INPUT VALUES: Enter the num coefficient [1,0,0.9]; Enter the den coefficient [1,0,0.4];
14
1.5
magnitude
0.5
0.1
0.2
0.3
0.7
0.8
0.9
0.1
0.2
0.3
0.7
0.8
0.9
15
AIM: To write a program to find DFT /IDFT of given DT signal SOFTWARE USED: MATLAB7.1 PROGRAM:
%program to perform N-point DFT of the given discrete time sequence% clc; clear all; N=input('Enter the length of sequence'); j=sqrt(-1); xn=input('Enter input sequence'); xk=zeros(1,N); for k=0:1:N-1 for n=0:1:N-1 xk(k+1)=xk(k+1)+xn(n+1)*exp(j*2*pi*k*n/N); end end disp('The DFT sequence is,');xk disp('Magnitude sequence is,'); magxk=abs(xk) disp('Phase sequence is,'); phaxk=angle(xk) wk=0:1:N-1; subplot(2,1,1); stem(wk,magxk); title('Magnitude Spectrum'); xlabel('k');ylabel('magnitude'); subplot(2,1,2); stem(wk,phaxk); title('Phase Spectrum'); xlabel('k');ylabel('phase');
INPUT VALUES:
16
Enter the length of sequence[4] Enter input sequence[1 1 2 3] The DFT sequence is, xk = 7.0000 -1.0000 + 2.0000i -1.0000 - 0.0000i -1.0000 - 2.0000i
Magnitude sequence is, magxk = 7.0000 2.2361 1.0000 2.2361 Phase sequence is, phaxk = 0 2.0344 -3.1416 -2.0344
0.5
2.5
4 2 phase 0 -2 -4
0.5
1.5 k
2.5
17
%program to find the IDFT% clear all; clc; N=input('Enter the length of inverse DFT'); i=sqrt(-1); xk=input('Enter input sequence'); xn=zeros(1,N); for k=0:1:N-1 for n=0:1:N-1 xn(n+1)=xn(n+1)+ (xk(k+1)*exp(i*2*pi*k*n/N))/N; end end disp('The iDFT sequence is,');xn
INPUT VALUES: Enter the length of inverse DFT4 Enter input sequence[7.0000 -1.0000 + 2.0000i -1.0000 - 0.0000i -1.0000 - 2.0000i] OUTPUT VALUES: The iDFT sequence is, xn = 1.0000 1.0000 + 0.0000i 2.0000 - 0.0000i 3.0000 - 0.0000i
18
clc; clear all; close all; rp=input('enter the pass band ripple'); rs=input('enter the stop band ripple'); fp=input('enter the pass band frequency'); fs=input('enter the stop band frequency'); f=input('enter the sampling frequency'); wp=2*(fp/f); ws=2*(fs/f); num=-(20*log10(sqrt(rp*rs))-13); dem=(14.6*(fs-fp)/f); n=ceil(num/dem); n1=n+1; if (rem(n,2)~=0) n1=n; n=n-1; end y=boxcar(n1); b=fir1(n,wp, 'low' ,y); [h,o]=freqz(b,1,256); m=20*log10(abs(h)); plot(o/pi,m); ylabel('gain'); xlabel('normalized frequency'); title('rectangular low pass filter');
19
Enter the pass band ripple Enter the stop band ripple
[0.05]; [0.04];
Enter the pass band frequency [1200]; Enter the stop band frequency [2400]; Enter the sampling frequency [9000];
0.1
0.2
0.3
0.7
0.8
0.9
20
EXPT NO 8: IMPLEMENTATION OF HP FIR FILTER AIM: To write a program for implementation of HP FIR filter for a given sequences SOFTWARE USED: MATLAB7.1
PROGRAM:
%HP FIR Filter %
clc; clear all; close all; rp=input('enter the pass band ripple'); rs=input('enter the stop band ripple'); fp=input('enter the pass band frequency'); fs=input('enter the stop band frequency'); f=input('enter the sampling frequency'); wp=2*(fp/f); ws=2*(fs/f); num=-(20*log10(sqrt(rp*rs))-13); dem=(14.6*(fs-fp)/f); n=ceil(num/dem); n1=n+1; if (rem(n,2)~=0) n1=n; n=n-1; end y=boxcar(n1); b=fir1(n,wp, 'HIGH' ,y); [h,o]=freqz(b,1,256); m=20*log10(abs(h)); plot(o/pi,m); ylabel('gain'); xlabel('normalized frequency'); title('rectangular HIGH pass filter'); %b=fir1(n,wp,'high',y);
21
Input Values: Enter the pass band ripple Enter the stop band ripple Enter the pass band frequency Enter the stop band frequency Enter the sampling frequency [0.05]; [0.04]; [1200]; [2400]; [9000];
Output Waveform:
rectangular HIGH pass filter 10 0 -10 -20 -30 gain -40 -50 -60 -70 -80
0.1
0.2
0.3
0.7
0.8
0.9
22
EXPT NO 9: IMPLEMENTATION OF LP IIR FILTER AIM: To write a program for Implementation of LP IIR filter for a given sequences a)Using Butterworth Filter b) Using Chebyshev Filter. SOFTWARE USED: MATLAB7.1
PROGRAM:
%Implementation of LP IIR filter for a given sequences Using Butterworth Filter%
clc; clear all; close all; rp=input('enter the value of rp'); rs=input('enter the value of rs'); fp=input('enter the valuek if fp'); fs=input('enter the value of fs'); %%instalation of sapling freq%% fsp=1000; %%normalised frequencie%% w1=((2*fp)/fsp); w2=((2*fs)/fsp); %%order,cutoff freq.of the filter%% [n,wn]=buttord(w1,w2,rp,rs,'s'); [b,a]=butter(n,wn,'low','s'); w=0:0.01:pi; [h,om]=freqs(b,a,w); m=(20*(log10(abs(h)))); %%for phase response%% an=angle(h); %%plotting the graphs%% subplot(2,1,1); plot(om/pi,m,'*r'); xlabel('frequency'); ylabel('magnitude'); title('magnitude plot'); %%plotting the graphs%% subplot(2,1,2);
23
plot(om/pi,an,'--'); xlabel('frequency'); ylabel('phase in radians'); title('phase plot'); Input Values: Enter Enter Enter Enter the the the the value value value value of of of of rp rs fp fs [0.5]; [50]; [1200]; [2400];
Output Waveform:
0.1
0.2
0.3
0.4
0.7
0.8
0.9
4 phase in radians 2 0 -2 -4
0.1
0.2
0.3
0.4
0.7
0.8
0.9
Result: Hence we implemented LP IIR filter for a given sequences using Butterworth Filter
24
PROGRAM:
%Implementation of LP IIR filter for a given sequences Using Chebyshev Filter%
clc; clear all; close all; rp=input('enter the value of rp'); rs=input('enter the value of rs'); fp=input('enter the valuek if fp'); fs=input('enter the value of fs'); %%instalation of sapling freq% fsp=10000; %%normalised frequencie%% wp=((2*fp)/fsp); ws=((2*fs)/fsp); %%order,cutoff freq.of the filter%% [n,wn]=cheb1ord(wp,ws,rp,rs,'s'); [b,a]=cheby1(n,rp,wp,'low','s'); w=0:0.01:pi; [h,om]=freqs(b,a,w); m=(20*(log10(abs(h)))); %%for phase response%% an=angle(h); %%plotting the graphs%% subplot(2,1,1); plot(om/pi,m,'.r'); xlabel('normalized frequency'); ylabel('gain in db'); title('magnitude response in db'); %%plotting the graphs%% subplot(2,1,2); plot(om/pi,an,'--'); xlabel('frequency'); ylabel('phase in radians'); title('phase plot');
25
Input Values: Enter the value of rp Enter the value of rs Enter the value of fp Enter the value of fs [0.5]; [50]; [1200]; [2400];
Output Waveform:
magnitude response in db 0
gain in db
-50
-100
0.1
0.2
0.3
0.7
0.8
0.9
4 phase in radians 2 0 -2 -4
0.1
0.2
0.3
0.4
0.7
0.8
0.9
Result: Hence we implemented LP IIR filter for a given sequences using Chebyshev Filter
26
EXPT NO 10:IMPLEMENTATION OF HP IIR FILTER AIM: To write a program for Implementation of HP IIR filter for a given sequences a)Using Butterworth Filter b) Using Chebyshev Filter
SOFTWARE USED:
MATLAB7.1
PROGRAM:
%Implementation of HP IIR filter for a given sequences Using Butterworth Filter%
clc; clear all; close all; rp=input('enter the value of rp'); rs=input('enter the value of rs'); fp=input('enter the value of fp'); fs=input('enter the value of fs'); %%instalation of sapling freq% fsp=10000; %%normalised frequencie%% wp=((2*fp)/fsp); ws=((2*fs)/fsp); %%order,cutoff freq.of the filter%% [n,wn]=buttord(wp,ws,rp,rs,'s'); [b,a]=butter(n,wn,'high','s'); w=0:0.01:pi; [h,om]=freqs(b,a,w); m=(20*(log10(abs(h)))); %%for phase response%% an=angle(h); %%plotting the graphs%% subplot(2,1,1); plot(om/pi,m,'.r'); xlabel('normalized frequency'); ylabel('gain in db');
27
title('magnitude response in db'); %%plotting the graphs%% subplot(2,1,2); plot(om/pi,an,'--'); xlabel('frequency'); ylabel('phase in radians'); title('phase plot');
Input Values: Enter the value of rp Enter the value of rs Enter the value of fp Enter the value of fs Output Waveform:
magnitude response in db 0
gain in db
-100
-200
-300
0.1
0.2
0.3
0.7
0.8
0.9
4 phase in radians 2 0 -2 -4
0.1
0.2
0.3
0.4
0.7
0.8
0.9
Result: Hence we implemented HP IIR filter for a given sequences using Butterworth Filter
28
PROGRAM:
%Implementation of HP IIR filter for a given sequences Using Chebyshev Filter%
clc; clear all; close all; rp=input('enter the value of rp'); rs=input('enter the value of rs'); fp=input('enter the valuek if fp'); fs=input('enter the value of fs'); %%instalation of sapling freq% fsp=10000; %%normalised frequencie%% wp=((2*fp)/fsp); ws=((2*fs)/fsp); %%order,cutoff freq.of the filter%% [n,wn]=cheb1ord(wp,ws,rp,rs,'s'); [b,a]=cheby1(n,rp,wp,'high','s'); w=0:0.01:pi; [h,om]=freqs(b,a,w); m=(20*(log10(abs(h)))); %%for phase response%% an=angle(h); %%plotting the graphs%% subplot(2,1,1); plot(om/pi,m,'.r'); xlabel('normalized frequency'); ylabel('gain in db'); title('magnitude response in db'); %%plotting the graphs%% subplot(2,1,2); plot(om/pi,an,'--'); xlabel('frequency'); ylabel('phase in radians'); title('phase plot');
29
Input Values: Enter the value of rp Enter the value of rs Enter the value of fp Enter the value of fs Output Waveform:
magnitude plot 0
magnitude
-100
-200
-300
0.1
0.2
0.3
0.4
0.7
0.8
0.9
4 phase in radians 2 0 -2 -4
0.1
0.2
0.3
0.4
0.7
0.8
0.9
Result: Hence we implemented HP IIR filter for a given sequences using Chebyshev Filter
30
AIM: To write a program for Implementation of Decimation Process. SOFTWARE USED: MATLAB7.1
PROGRAM: % Implementation of Decimation Process% clc; clear all; close all; t=0:0.03:2; x=cos(2*pi*t); y=decimate(x,2); t1=decimate(t,2); %%Plotting Decimation Signals % Plot for Input signal subplot(2,1,1) stem(t,x) xlabel('Number of samples') ylabel('Amplitude') title('Input signal') % Plot for Decimation subplot(2,1,2) stem(t1,y) xlabel('Number of samples') ylabel('Amplitude') title('Decimated signal') %disp('GRAPHS:')
31
Output Waveform:
Input signal 1 0.5 Amplitude 0 -0.5 -1
0.2
0.4
0.6
1.4
1.6
1.8
1.5
32
AIM: To write a program for Implementation of Interpolation Process SOFTWARE USED: MATLAB7.1
PROGRAM: % Implementation of Interpolation Process% clc; clear all; close all; t=0:0.03:2; x=cos(2*pi*t); y1=interp(x,2); t2=interp(t,2); %Plotting Interpolation Signals % Plot for Input signal subplot(2,1,1) stem(t,x) xlabel('Number of samples') ylabel('Amplitude') title('Input signal') % Plot for Interpolation subplot(2,1,2) stem(t2,y1) xlabel('Number of samples') ylabel('Amplitude') title('Interpolated signal') disp('GRAPHS:')
33
Output Waveform:
0.2
0.4
0.6
1.4
1.6
1.8
2 1 Amplitude 0 -1 -2
0.2
0.4
0.6
1.4
1.6
1.8
34
AIM: To write a program for Generation of DTMF signals SOFTWARE USED: MATLAB7.1
PROGRAM: clc; clear all; %DTMF Generation% d = input('enter the telephone digit= ','s'); symbol = abs(d); tm = [49 50 51 65; 52 53 54 66; 55 56 57 67; 42 48 35 68]; for i = 1:4 for j = 1:4 if tm(i,j) == symbol, break end end if tm(i,j) == symbol, break end end f1 = [697 770 852 941]; f2 = [1209 1336 1477 1633]; fs = 8000; dt = 1/fs; t = 0:dt:1023/fs; N = length(t); x = sin(2*pi*f1(i)*t)+ sin(2*pi*f2(j)*t);
35
xf = 1/N*abs(fft(x,N)); f = fs*(0:round(N/2))/N; f = f(1:round(N/2)); figure(1); subplot(211) plot(t,x) subplot(212) stem(f,xf(1:round(N/2))) %DTMF Detection% xfs = fliplr(sort(xf(1:round(N/2)))); fd = []; for k = 1:N/2 if((xf(k) == xfs(1)) | (xf(k) == xfs(2))) fd = [fd k]; end end fd =sort(fd); dtmf1 = round(f(fd(1))); dtmf2 = round(f(fd(2))); for p = 1:4 if ((dtmf1 > f1(p)-5) & (dtmf1 < f1(p)+5)) dtmf1 = f1(p); break end end for q = 1:4 if ((dtmf2 > f2(q)-5) & (dtmf2 < f2(q)+5)) dtmf2 = f2(q); break end end disp('The tone frequencies are'); dtmf1 dtmf2
36
Output Waveform:
2 1 0 -1 -2
0.02
0.04
0.06
0.08
0.1
0.12
0.14
0.5 0.4 0.3 0.2 0.1 0 0 500 1000 1500 2000 2500 3000 3500 4000