Code:
x1 = [1,2,2,1]; x2 = [1,-1,-1,1]; x3 = conv (x1,x2); % N = 5N1 = 0:1:length (x1) -1;n2 = 0:1:length (x2) -1;n3 = 0:1:length (x3) -1;%%-------------------------------------------- ---------------------percent START a%%-----------------------------------------------------------------Figu Re (' Numbertitle ', ' off ', ' Name ', ' exameple5.16a ') set (GCF, ' Color ', ' white '); Subplot (3,1,1); Stem (n1,x1); Title (' Sequence x1 (n) '); Axis ([0,5,0,5]); Xlabel (' n '); Ylabel (' x1 (n) '); Grid On;subplot (3,1,2); Stem (n2,x2); Title (' Sequence x2 (n) '); Axis ([0,5,0,5]); Xlabel (' n '); Ylabel (' X2 (n) '); Grid On;subplot (3,1,3); Stem (n3,x3); Title (' Linear convolution sequence x3 (n) '); Axis ([0,10,-3,5]); Xlabel (' n '); Ylabel (' x3 (n) '); Grid on;%%-----------------------------------------------------------------percent END a%%---------------- -------------------------------------------------x4 = CIRCONVT (x1,x2,7); % N = 7n4 = 0:1:length (x4) -1;%%-----------------------------------------------------------------percent START b%%-----------------------------------------------------------------Fig Ure (' Numbertitle ', ' off ', ' Name ', ' exameple5.16b ') set (GCF, ' Color ', ' white '); Subplot (3,1,1); Stem (n1,x1); Title (' Sequence x1 (n) '); Axis ([0,5,0,5]); Xlabel (' n '); Ylabel (' x1 (n) '); Grid On;subplot (3,1,2); Stem (n2,x2); Title (' Sequence x2 (n) '); Axis ([0,5,0,5]); Xlabel (' n '); Ylabel (' X2 (n) '); Grid On;subplot (3,1,3); Stem (n4,x4); Title (' Circularly convolution sequence x4 (n) '); Axis ([0,10,-3,5]); Xlabel (' n '); Ylabel (' x4 (n) '); Grid on;%%-----------------------------------------------------------------percent END b%%---------------- -------------------------------------------------
Operation Result:
"DSP using MATLAB" Example Example5.16