Linear Convolution using Matlab Code

9,942 views 2 slides Apr 15, 2015
Slide 1
Slide 1 of 2
Slide 1
1
Slide 2
2

About This Presentation

Matlab Coding for Linear convulation


Slide Content

ExperimentNo:-02
Aim:MaketwodifferentfunctiononeforLinearConvolutionand
secondforCircularConvolution,whichareabletoperformersame
operationasinbuiltfunctions/command"conv"and"cconv"
respectively.
PROCEDURE:-
LinearConvolution
OpenMATLAB
OpennewM-file
Typetheprogram
Saveincurrentdirectory
CompileandRuntheprogram
Fortheoutputseecommandwindow\Figurewindow
Step1.Takeinputsignalsx[n]andh[n]asvectors.
Step2.Computelengthoftheinputsignals(xandh)and
convolutedsignal(y),andstoreitinm,nandLrespectively.
Step3.Useforlooptocomputesamplesofyfrom1toL.(Usedthe
requiredexpression)
Step4.Plot/stemvectoryasitisconvolutionofxandh.
Step5.Manageandlabelthex-axesinproperrange.
Step6.Generalizedthisfunctionforanyvalueofxandh.
PROGRAM:-
function[y]=shyamconv(x,h)
m=length(x)
l=length(h)

n=m+l-1
fort=1:n
y(t)=0
fork=max(1,t-(m-1)):min(t,m)
y(t)=y(t)+x(k).*h(t-k+1)
end
end
stem(y)
conv(x,h)
End
RESULTS:-ThustheMATLABprogramforlinearconvolution
usingfunctiondeclarationinMATLABwasperformedandthe
outputwasverified.
OUTPUT:
Tags