1、1、已知 x(n)=n,0n99 ,h(n)=n+1, 0n4,使用 C 语言编译出重叠相加法,再利用 Matlab 编写重叠相加法和重叠保留法程序,计算 x(n)和 h(n)的卷积。(1) C 语言程序及结果截图#includevoid main ()int a105, b5,c104;int i,j,k,t,r=0,s=0,p;a0=0;int x1020,xnew51020,xnewl1018;for(i=0;i0)n=10*i;m=10*(i+1)+3;elsen=0;m=13;for(j=n,k=0;j=0;k-)xnewijk+i=xnewijk;for(i=0;i5;i+)/移动
2、 n 位后,在数组前面补 n 个零for(j=0;j10;j+)for(k=0;ki;k+) xnewijk=0;for(i=0;i5;i+)/各个数组元素最后一位补 4-n 个 0for(j=0;j10;j+)for(k=17,p=0;p(4-i);k-, p+) xnewijk=0;for(i=0;i10;i+)for(j=0;j18;j+)xnewlij=0;for(i=0;i10;i+)/将各小段数组的对应各元素相加for(j=0;j18;j+)for(k=0;k5;k+)xnewlij+=xnewkij;for(i=0;i104;i+)ci=0;for(i=0;i10;i+)/去除重
3、叠部分,合成最终结果n=i*10;m=10*(i+1)-1;for(j=n,k=4;jm,k14;j+,k+)cj=xnewlik;for(i=100,j=14;i105,j18;i+,j+)ci=xnewl9j;for(k=0;k104;k+)/输出最终结果 r+;if(r-1)%10=0)printf(“n“);s+;printf(“第 %d 行 “,s);printf(“%d “,ck); scanf(“输入数据“);(2) Matlab 运行结果在命令框输入以下命令,调取已编好的三个程序 conv(hn, xn)、 overlap_add(xn, hn, N) overlap_save
4、(xn, hn, N),得出一下结果:n = 0:9;xn = n+1;hn = 1,0,-1;N = 6;y1 = conv(hn, xn)y2 = overlap_add(xn, hn, N)y3 = overlap_save(xn, hn, N) 重叠相加法计算结果y2 =1.0e+003 *Columns 1 through 100.0000 0.0010 0.0040 0.0100 0.0200 0.0350 0.0500 0.0650 0.0800 0.0950Columns 11 through 200.1100 0.1250 0.1400 0.1550 0.1700 0.185
5、0 0.2000 0.2150 0.2300 0.2450Columns 21 through 300.2600 0.2750 0.2900 0.3050 0.3200 0.3350 0.3500 0.3650 0.3800 0.3950Columns 31 through 400.4100 0.4250 0.4400 0.4550 0.4700 0.4850 0.5000 0.5150 0.5300 0.5450Columns 41 through 500.5600 0.5750 0.5900 0.6050 0.6200 0.6350 0.6500 0.6650 0.6800 0.6950C
6、olumns 51 through 600.7100 0.7250 0.7400 0.7550 0.7700 0.7850 0.8000 0.8150 0.8300 0.8450Columns 61 through 700.8600 0.8750 0.8900 0.9050 0.9200 0.9350 0.9500 0.9650 0.9800 0.9950Columns 71 through 801.0100 1.0250 1.0400 1.0550 1.0700 1.0850 1.1000 1.1150 1.1300 1.1450Columns 81 through 901.1600 1.1
7、750 1.1900 1.2050 1.2200 1.2350 1.2500 1.2650 1.2800 1.2950Columns 91 through 1001.3100 1.3250 1.3400 1.3550 1.3700 1.3850 1.4000 1.4150 1.4300 1.4450Columns 101 through 1041.3600 1.1740 0.8860 0.4950 重叠保留法计算结果y3 =1.0e+003 *Columns 1 through 100.0000 0.0010 0.0040 0.0100 0.0200 0.0350 0.0500 0.0650
8、0.0800 0.0950Columns 11 through 200.1100 0.1250 0.1400 0.1550 0.1700 0.1850 0.2000 0.2150 0.2300 0.2450Columns 21 through 300.2600 0.2750 0.2900 0.3050 0.3200 0.3350 0.3500 0.3650 0.3800 0.3950Columns 31 through 400.4100 0.4250 0.4400 0.4550 0.4700 0.4850 0.5000 0.5150 0.5300 0.5450Columns 41 throug
9、h 500.5600 0.5750 0.5900 0.6050 0.6200 0.6350 0.6500 0.6650 0.6800 0.6950Columns 51 through 600.7100 0.7250 0.7400 0.7550 0.7700 0.7850 0.8000 0.8150 0.8300 0.8450Columns 61 through 700.8600 0.8750 0.8900 0.9050 0.9200 0.9350 0.9500 0.9650 0.9800 0.9950Columns 71 through 801.0100 1.0250 1.0400 1.0550 1.0700 1.0850 1.1000 1.1150 1.1300 1.1450Columns 81 through 901.1600 1.1750 1.1900 1.2050 1.2200 1.2350 1.2500 1.2650 1.2800 1.2950Columns 91 through 1001.3100 1.3250 1.3400 1.3550 1.3700 1.3850 1.4000 1.4150 1.4300 1.4450Columns 101 through 1041.3600 1.1740 0.8860 0.4950