Professional Documents
Culture Documents
LaboratoryManual
For
PREFACE
Prof. A. P. Phatale.
SUBJECT INDEX
Title
Page no.
04
04
3. Lab Exercises
1. Introduction to matlab
2. Generation of signal
3. To verify the partial fraction expansion of the ztransform.
4. To verify impulse response.
5.
6. Design of IIR Filter
7. Illustration of interpolation process.
8. Illustration of decimal process
9. Spectral analysis using DFT.
4. Quiz for the subject
5. Conduction of viva voce examination
6. Evaluation and marking scheme
05
08
Do not handle DSP Starter kit without reading the instructions/Instruction manuals.
Refer Matlab Help for debugging the program.
Go through Matlab Demos of Signal Processing tool box.
Strictly observe the instructions given by the teacher/Lab Instructor.
3.LabExercises:
Exercise No1: ( 2 Hours) 1 Practical
Aim:Generationofdiscretetimesignallike
a)sinusoidal
b) step
c) ramp
d) impulse
e) realvalued
f) complexvalued
g) noise
ThesearethebasicdiscretesignalsusedinDSP. Plotallthesignals.
Step:1.
GenerateSinusoidalsignal
Discretesinusoidalsignalisrepresentedbytheequation
x(n)=ASin(2 Pfn)foralln
fs
A=peakamplitude
f=signalfrequency
fs=samplingfrequency
n=nthsample
function[x,n]=sinusoidal(n1,n2)
n=0:100
x=5*sin(2*0.05*pi*n)+sin(0.01*pi*n)
stem(n,x)
title('Sinusoidalsequence')
xlabel('samples')
ylabel('magnitude')
Step:2.
GenerateStepsignal
Discretestepsignalisrepresentedbytheequation
x(n)=1
foralln>0
=0otherwise
function[x,n]=stepseq(n0,n1,n2)
n=5:10
x=[(n4)>=0]
stem(n,x)
title('unitstepsequencedelayedbyfoursamples')
xlabel('samples')
ylabel('stepsequence')
Step:3.
Generaterampsignal
Discreterampsignalisrepresentedbytheequation
x(n)=nforalln>0
=0otherwise
function[x,n]=rampseq(n0,n1)
n=0:10
x=n
stem(n,x)
title('unitrampsequencedelayedbyfoursamples')
xlabel('samples')
ylabel('rampsequence')
Steps:4. Generatecomplexvaluedsignal
Discretecomplexvaluedsignalisrepresentedbytheequation
x(n)=exp(a+jb)nforalln>0
function[x,n]=compexp(n1,n2)
n=10:50
x=[exp((0.2+i*2)*n)]
stem(n,x)
title('Complexvaluedexponentialsequence')
xlabel('samples')
ylabel('complexvaluedexponentialsequence')
Steps:5. Generateimpulsesignal
Discreteimpulsesignalisrepresentedbytheequation
x(n)=1foralln=0
=0otherwise
x=2*impseq(5,0,20)
y=3*impseq(1,0,20)
a=x+y
stem(a)
title('unitimpulsesequence')
xlabel('samples')
ylabel('impulsesequence')
Steps:6. Generatenoisesignal
n=50
x=rand(n,1)
%generatetheuncorruptedsignal
m=0:1:n1
s=2*m.*(0.9.^m)
subplot(2,1,1)
stem(m,s)
title('Uncorruptedsequence')
xlabel('Timeindex')
ylabel('Amplitude')
subplot(2,1,2)
stem(m,x)
title('Noise')
xlabel('Timeindex')
ylabel('Amplitude')
Y(k)= x(k).h(nk)forall k
n=
Implementtheequationon4_point(orvariety)x(n)&h(n)anddisplayy(n).
%Illustrationofconvolution
x=input('typetheinputsequence')
h=input('typetheimpulseresponse')
y=conv(x,h)
m=length(y)1
n=0:1:m
disp('outputsequence')
disp(y)
stem(n,y)
xlabel('Timeindex')
ylabel('Amplitude')
Anothersampleprogramforconvolutionwhereintimereferenceisalsodisplayed.
%Illustrationofconvolution
nx=[1:2]
x=input('typetheinputsequence')
nh=[1:4]
h=input('typetheimpulseresponse')
nyb=nx(1)+nh(1)
nye=nx(length(x))+nh(length(h))
ny=[nyb:nye]
y=conv(x,h)
disp(y)
stem(ny,y)
xlabel('Timeindex')
ylabel('Amplitude')
Rxy(k)= x(n).y(nk)
n=
Theautocorrelationisgivenby
Rxy(k)= x(n).y(nk)
n=
%computationofcrosscorrelationsequence
x=input('typeinthereferencesequence=')
y=input('typeinthesecondsequence=')
%computethecorrelationsequence
n1=length(y)1
n2=length(x)1
r=xcorr(x,y)%herethelengthofx=lengthofy
%r=conv(x,fliplr(y))
%k=(n1):n2'
stem(r)
%computationofautocorrelationofasequence
x=input('typeinthereferencesequence=')
%computethecorrelationsequence
%r=xcorr(x)
r=conv(x,fliplr(x))
stem(r)
foranyarbitrary8_pointsequencex(n)oflengthNplotthefrequency
responseandphaseresponse.
%IllustrationofDFTcomputation
%wedetermineMpointDFTofNpointu[n]=10<=n<=N1else0
%Nbethelengthofthesequenceand
%Mpointdftiscalculated
N=input('typethelengthofthesequence')
M=input('typethelengthoftheDFT=')
u=[ones(1,N)]
U=fft(u,M)
t=0:1:N1
stem(t,u)
title('Originaltimedomainsequence')
xlabel('n')
ylabel('amplitude')
pause
subplot(2,1,1)
k=0:1:M1
stem(k,abs(U))
title('MagnitudeofDFTsamples')
xlabel('frequencyindexk')
ylabel('magnitude')
subplot(2,1,2)
k=0:1:M1
stem(k,angle(U))
title('PhaseofDFTsamples')
xlabel('frequencyindexk')
ylabel('phase')
%programtodesignButterworthlowpassfilter
N=input('typefilterorder')
wn=input('3dbcutofffrequency')
[num,den]=butter(N,wn,'s')
omega=[0:200:12000*pi]
h=freqs(num,den,omega)
plot(omega/(2*pi),20*log10(abs(h)))
xlabel('freq.inHz')
ylabel('Gainindb')
floatstep(PI/180)*6
unsignedintprocessingload=BASELOAD
externvoidload(unsignedintloadvalue)
staticintprocessing(int*input,int*output)
staticvoiddataIO(void)
voidmain()
{
int*input=&inp_buffer[0]
int*output=&out_buffer[0]
puts(volumeexamplestarted\n)
/*initializationofTaylorseries*/
ar0=cos(step)
ar1=sin(step)
ar2=sin((2*step))
while(TRUE)
{
dataIO()
processing(input,output)
}
}
Staticintprocessing(int*input,int*output)
{
intsize=BUFSIZE
intdata
interror
intdelta=2500
floatvalue
while(size)
{value=(2*ar0*ar1)ar2
data=value*16000
ar2=ar1
ar1=value
*input++=data
error=datapredict
if(error>0)
predict=delta
else
if(error<0)
prdict=delta
*output++=predict
}
load(processingload)
returnTRUE
}
staticvoiddataIO()
{
return
}
4.Quizonthesubject:
1).Signalsarethesignalsrepeatingafterspecificperiod.
a]Energy
b]Digital
c]Periodic
2)Thesystemissaidtobe ortohavememory.
a]Dynamic
b]Recursive
c]Stable
3)Ify(n)=nx(n)thenthesystemis
a]Causual
b]Recursive
c]dynamic
4)IfthesignalisinfinitedurationandbothsidedthenitsROCis
a]anannularring
b]entirezplaneexceptz=0
c]entirezplaneexceptz=
5)IfthesequenceisrealandeventhentheDFTconsistsof
a]realandevenparts
b]purelyimaginaryparts
5.ConductionofVivaVoceExaminations:
Questions to be prepared for viva voce examinations
1. Define Discrete time Signal .
2. State the advantages of Digital Signal Processing.
3. What do you mean by aliasing? How to overcome?
4. Define LTI system.
5. What is the significance of convolution.
6. State the applications of autocorrelation and cross correlation.
7. Compare IIR with FIR filters.
8.What are linear phase filters ?
9. List different applications of DSP.
10.Explain architectural overview of TMS 3205402 DSK.
6.Evaluationandmarkingsystem:
As per JNEC format/University marking scheme.