4、,2,2);stem([0:length(h)-1],h);ylabel('h(n)');xlabel('Timeindexn')subplot(2,2,3);stem([0:length(y)-1],y);ylabel('y(n)=x(n)*h(n)');xlabel('Timeindexn');第二章2.1.2.用DFT计算下列信号的频谱:(1)N=30;%数据的长度L=1024;%DFT的点数f=1/16;fs=600;T=1/fs;ws=2*pi*fs;t=(0:N-1)*T;x=5*cos(2*pi*f*
5、t+pi/4);X=fftshift(fft(x,L));w=(-ws/2+(0:L-1)*ws/L)/(2*pi);plot(w,abs(X));ylabel('幅度谱')2.1.(3)N=30;L=1024;f1=0.5;f2=4;fs=600;T=1/fs;ws=2*pi*fs;t=(0:N-1)*T;x=2*sin(2*pi*f1*t)+sin(2*pi*f2*t);X=fftshift(fft(x,L));w=(-ws/2+(0:L-1)*ws/L)/(2*pi);plot(w,abs(X));ylabe
6、l('幅度谱')第三章5.采用脉冲响应不变法和双线性变换法设计巴特沃斯数字低通滤波器,满足下列指标:通带边缘频率:0.4,通带衰减:0.5dB;阻带边缘频率:06,阻带衰减:50dBWp=04*pi;Ws=0.6*pi;Ap=0.5;As=50;Fs=1;wp=Wp*Fs;ws=Ws*Fs;N=buttord(wp,ws,Ap,As,'s');wc=wp/(10^(0.1*Ap)-1)^(1/2/N);[numa,dena]=butter(N,wc,'s');[numd,dend]=impinvar(numa,de
7、na,Fs);w=linspace(0,pi,512);h=freqz(numd,dend,w);norm=max(abs(h));numd=numd/norm;plot(w/pi,20*log10(abs(h)/norm))w=[Wp,Ws];h=freqz(numd,dend,w);fprintf('Ap=%.4',-20*log10(abs(h(1))));fprintf('As=%.4',-20*log10(abs(h(1))));Wp=04*pi;Ws=0.6*pi;Ap=0.5;As=50;Fs
8、=0.5;wp=0.7265;ws=1.3764;N=buttord(wp,ws,Ap,As,'s');wc=wp/(10^(0.1*Ap)-1)^(1/2/N);[numa,dena]=butter(N,wc,'s');[numd,dend]=bilinear(numa,dena,Fs);w=linspace(0,pi,512);h=freqz(numd,