您好,欢迎访问三七文档
当前位置:首页 > 临时分类 > MATLAB 数字信号处理参考
图一图二图三图四figureN4=32;n4=1:N4;T4=0.004;xn4=cos(2*pi*50*n4*T4);xk4=fft(xn4,N4);subplot(2,2,1);stem(n4,xn4,'.');xlabel('cos(2*pi*50*n4*T4)')subplot(2,2,2);stem(n4,xk4,'.');xlabel('T=0.004,N=32');N5=64;n5=1:N5;T5=0.000625;xn5=cos(2*pi*50*n5*T5);xk5=fft(xn5,N5);subplot(2,2,3);stem(n5,xn5,'.');xlabel('cos(2*pi*50*n5*T5)')subplot(2,2,4);stem(n5,xk5,'.');xlabel('T=0.000625,N=64');图形见图三和图四4、利用编制的计算卷积的计算程序,分别给出一下三组函数的卷积结果。(1)其它01401)(nnx14054)(nnhn(2)其它0901)(nnx190)5.0sin(5.0)(nnnh(3)90)1.01()(nnnx901.0)(nnnh、程序如下:n=0:14;x1n=ones(1,15);h1n=0.8.^n;y1n=conv(x1n,h1n);subplot(3,3,1);stem(n,x1n,'.');xlabel('xn=1,0=n=14');subplot(3,3,4);stem(n,h1n,'.');xlabel('hn=0.8^n,0=n=14');subplot(3,3,7);stem(y1n,'.');xlabel('卷积结果yn');n2=0:19;x2n=ones(1,9);h2n=0.5*sin(0.5*n2);y2n=conv(x2n,h2n);subplot(3,3,2);stem(x2n,'.');xlabel('xn=1,0=n=9');subplot(3,3,5);stem(n2,h2n,'.');xlabel('hn=0.5sin(0.5n)');subplot(3,3,8);stem(y2n,'.');xlabel('卷积结果yn');n3=0:9;x3n=1-0.1*n3;h3n=0.1*n3;y3n=conv(x3n,h3n);subplot(3,3,3);stem(n3,x3n,'.');xlabel('xn=1-0.1n,0=n=9');subplot(3,3,6);stem(n3,h3n,'.');xlabel('hn=0.n,0=n=9');subplot(3,3,9);stem(y3n,'.');xlabel('卷积结果yn');结果见图五图一图二图三图四图五图一图二图三图四fp=0.2KHz,Rp=1dB,fs=0.3KHz,As=25dB,T=1ms;分别用脉冲响应不变法及双线性变换法设计一Butterworth数字低通滤波器双线性设计法程序如下wp=0.4*pi;ws=0.6*pi;Rp=1;As=25;T=1;Fs=1/T;OmegaP=(2/T)*tan(wp/2);OmegaS=(2/T)*tan(ws/2);ep=sqrt(10^(Rp/10)-1);Ripple=sqrt(1/(1+ep*ep));Attn=1/(10^(As/20));N=ceil((log10((10^(Rp/10)-1)/(10^(As/10)-1)))/(2*log10(OmegaP/OmegaS)));OmegaC=OmegaP/((10^(Rp/10)-1)^(1/(2*N)));[B,A]=butter(N,OmegaC,'s');W=(0:500)*pi/500;[H]=freqs(B,A,W);mag=abs(H);db1=20*log10((mag+eps)/max(mag));[b,a]=bilinear(B,A,T);[h,w]=freqz(b,a,1000,'whole');h=(h(1:501))';w=(w(1:501))';m=abs(h);db2=20*log10((m+eps)/max(m));figure(1);subplot(2,3,1);plot(w/pi,mag);title('幅度');ylabel('模拟滤波器');axis([0,1,0,1.1])set(gca,'XtickMode','manual','XTick',[0,0.4,0.6,1]);set(gca,'YtickMode','manual','YTick',[0,Attn,Ripple,1]);gridsubplot(2,3,2);plot(w/pi,db1);title('幅度(db)')axis([0,1,-30,5])set(gca,'XtickMode','manual','XTick',[0,0.4,0.6,1]);set(gca,'YtickMode','manual','YTick',[-30,-15,-1,0]);gridsubplot(2,3,4);plot(w/pi,m);xlabel('频率单位:pi');ylabel('数字滤波器');axis([0,1,0,1.1])set(gca,'XtickMode','manual','XTick',[0,0.4,0.6,1]);set(gca,'YtickMode','manual','YTick',[0,Attn,Ripple,1]);gridsubplot(2,3,5);plot(w/pi,db2);xlabel('频率单位:pi');axis([0,1,-30,5])set(gca,'XtickMode','manual','XTick',[0,0.4,0.6,1]);set(gca,'YtickMode','manual','YTick',[-30,-15,-1,0]);gridsubplot(2,3,3);plot(w/pi,angle(h)/pi);title('相位');subplot(2,3,6);plot(w/pi,angle(H)/pi);xlabel('pi归一');实验结果见图三冲击不变法设计如下wp=0.4*pi;%ws=0.6*pi;Rp=1;As=25;Fs=1000;OmegaP=wp*Fs;OmegaS=ws*Fs;ep=sqrt(10^(Rp/10)-1);Ripple=sqrt(1/(1+ep*ep))Attn=1/(10^(As/20));%[N,OmegaC]=buttord(OmegaP,OmegaS,Rp,As,'s');[z0,p0,k0]=buttap(N);p=p0*OmegaC;z=z0*OmegaC;k=k0*OmegaC^N;ba=k*real(poly(z));aa=real(poly(p));[bd,ad]=impinvar(ba,aa,Fs);%[H,W]=freqz(bd,ad,1000,'whole');H=(H(1:1:501))';W=(W(1:1:501))';mag=abs(H);db=20*log10((mag+eps)/max(mag));%化为分贝值pha=angle(H);grd=grpdelay(bd,ad,W);subplot(2,2,1);plot(W/pi,mag);title('幅度响应');xlabel('');ylabel('|H|');axis([0,1,0,1.1])set(gca,'XtickMode','manual','XTick',[0,0.4,0.6,1]);gridon;set(gca,'YtickMode','manual','YTick',[0,Attn,Ripple,1]);subplot(2,2,3);plot(W/pi,db);title('幅度(单位:db)');xlabel('频率(单位:pi)');ylabel('分贝');axis([0,1,-100,50]);set(gca,'XtickMode','manual','XTick',[0,0.4,0.6,1]);set(gca,'YtickMode','manual','YTick',[-100,-50,0,50]);gridon;subplot(2,2,2);plot(W/pi,pha/pi);title('相位响应');xlabel('');ylabel('单位:pi');axis([0,1,-1,1]);set(gca,'XtickMode','manual','XTick',[0,0.4,0.6,1]);gridon;set(gca,'YtickMode','manual','YTick',[-1,0,1]);subplot(2,2,4);plot(W/pi,grd);title('群延迟');xlabel('频率(单位:pi)');ylabel('样本');axis([0,1,0,10]);set(gca,'XtickMode','manual','XTick',[0,0.4,0.6,1]);gridon;set(gca,'YtickMode','manual','YTick',[0:2:10]);实验结果见图四subplot(3,3,3);stem(n,x3,'.');xlabel('sin(0.5*pi*n)')subplot(3,3,6);stem(y31,'.');axis([10,60,-2,2])subplot(3,3,9);stem(y32,'.');xlabel('阻带')axis([10,60,-2,2])图一图二图三下面对五种窗函数进行比较程序如下:N=44;ta=(N-1)/2;w1=0.3*pi;w2=0.5*pi;n=0:N-1;wn1=(hamming(N))';wn2=(boxcar(N))';wn3=(hanning(N))';wn4=(blackman(N))';wn5=(kaiser(N))';hn=(sin(w2*(n-ta))-sin(w1*(n-ta)))./(pi*(n-ta));h1=hn.*wn1;[H1,w1]=freqz(h1,[1],1000,'whole');A1=abs(H1);db1=20*log10((A1+eps)./max(A1));ph1=angle(H1);h2=hn.*wn2;[H2,w2]=freqz(h2,[1],1000,'whole');A2=abs(H2);db2=20*log10((A2+eps)./max(A2));ph2=angle(H2);h3=hn.*wn3;[H3,w3]=freqz(h3,[1],1000,'whole');A3=abs(H3);db3=20*log10((A3+eps)./max(A3));ph3=angle(H3);h4=hn.*wn4;[H4,w4]=freqz(h4,[1],1000,'whole');A4=abs(H4);db4=20*log10((A4+eps)./max(A4));ph4=angle(H4);h5=hn.*wn5;[H5,w5]=freqz(h5,[1],1000,'whole');A5=abs(H5);db5=20*log10((A5+eps)./max(A5));ph5=angle(H5);subplot(5,3,1);stem(n,wn1,'.');subplot(5,3,2);plot(w1/pi,db1);axis([02-2000])subplot(5,3,3);plot(w1/pi,ph1/pi);subplot(5,3,4);stem(n,wn2,'.');subplot(5,3,5);plot(w2/pi,db2);axis([02-2000])subplot(5,3,6);plot(w2/pi,ph2/pi);
本文标题:MATLAB 数字信号处理参考
链接地址:https://www.777doc.com/doc-3869640 .html