Title: >> y=[zeros(1,5),10*(1-0.9.^(1:9)),10*(1-0.9^10)*0.9.^(0:40)]; stem(-5:49,y);title('y(n)')
1(No Transcript)
2gtgt yzeros(1,5),10(1-0.9.(19)),10(1-0.910)0
.9.(040) stem(-549,y)title('y(n)')
3gtgt nx-33x3,11,7,0,-1,4,2nh-14h2,3,0,-5
,2,1 gtgt subplot(2,1,1) stem(nx,x)axis(-5,5,-5
.5,11.5)title('x(n)') gtgt subplot(2,1,2)
stem(nh,h)axis(-5,5,-5.5,11.5)title('h(n)')
4gtgt y,nsigmult(x,nx,h2,nh2) gtgt sum(y) ans
6
5gtgt h2,nh2sigshift(h1,nh1,2) gtgt
subplot(2,1,1) stem(nx,x)axis(-5,5,-5.5,11.5)
title('x(k)') gtgt subplot(2,1,2)
stem(nh2,h2)axis(-5,5,-5.5,11.5)title('h(2-k)'
)
gtgt y,nsigmult(x,nx,h2,nh2) gtgt sum(y) ans
41
6Convolution in MATLAB
yconv(x,h) CONV computes the convolution
between two finite sequences
gtgt yconv(x,h) y 6 31 47 6
-51 -5 41 18 -22 -3 8 2
7function y,nyconv_m(x,nx,h,nh) Modifeid
convolution routine for signal processing
nybnx(1)nh(1) nyenx(end)nh(end) nynybnye
yconv(x,h)
gtgt y,nyconv_m(x,nx,h,nh) y 6 31
47 6 -51 -5 41 18 -22 -3
8 2 ny -4 -3 -2 -1 0
1 2 3 4 5 6 7
8yfilter(b,a,x) bb0,b1,,bM aa0,a1,,aN
gtgt b1 a1,-1,0.9 gtgt xstepsep(0,-20,120)
sfilter(b,a,x) gtgt n-20120 stem(n,s)
title('step response')
9gtgt xstepseq(0,-5,49)-stepseq(10,-5,49) gtgt
b1a1,-0.9y1filter(b,a,x) gtgt
y2zeros(1,5),10(1-0.9.(19)),10(1-0.910)0.9
.(040) gtgt n-549 gtgt subplot(2,1,1)
stem(n,y1) title('result via using filter') gtgt
subplot(2,1,2) stem(n,y2) title('result via
manual convolution')
10himpz(b,a,n) n sample indices
gtgt b1,2a1,-3,-4 gtgt n030
h1impz(b,a,n) gtgt h2-0.2(-1).n1.24.n gtgt
stem(n,h1'-h2) title('h1(n)-h2(n)')