matlab上机完美版解析.docx

上传人:b****8 文档编号:30387505 上传时间:2023-08-14 格式:DOCX 页数:24 大小:160.17KB
下载 相关 举报
matlab上机完美版解析.docx_第1页
第1页 / 共24页
matlab上机完美版解析.docx_第2页
第2页 / 共24页
matlab上机完美版解析.docx_第3页
第3页 / 共24页
matlab上机完美版解析.docx_第4页
第4页 / 共24页
matlab上机完美版解析.docx_第5页
第5页 / 共24页
点击查看更多>>
下载资源
资源描述

matlab上机完美版解析.docx

《matlab上机完美版解析.docx》由会员分享,可在线阅读,更多相关《matlab上机完美版解析.docx(24页珍藏版)》请在冰豆网上搜索。

matlab上机完美版解析.docx

matlab上机完美版解析

1.已知3阶椭圆IIR数字低通滤波器的性能指标为:

通带截止频率0.4π,通带波纹为0.6dB,最小阻带衰减为32dB。

设计一个6阶全通滤波器对其通带的群延时进行均衡。

绘制低通滤波器和级联滤波器的群延时。

%Q1_solution

%ellip(N,Ap,Ast,Wp)//双线性法设计低通滤波器

%N--->Theorderofthefilter

%Ap-->rippleinthepassband

%Ast->astopbandRsdBdownfromthepeakvalueinthepassband

%Wp-->thepassbandwidth

[be,ae]=ellip(3,0.6,32,0.4);

hellip=dfilt.df2(be,ae);

f=0:

0.001:

0.4;

g=grpdelay(hellip,f,2);

g1=max(g)-g;

[b,a,tau]=iirgrpdelay(6,f,[00.4],g1);

hallpass=dfilt.df2(b,a);//级联

hoverall=cascade(hallpass,hellip);

hFVT=fvtool([hellip,hoverall]);

set(hFVT,'Filter',[hellip,hoverall]);

legend(hFVT,'LowpassEllipticfilter','Compensatedfilter');//添加图例的标注

 

clear;

[num1,den1]=ellip(3,0.6,32,0.4);

[GdH,w]=grpdelay(num1,den1,512);

plot(w/pi,GdH);grid

xlabel('\omega/\pi');ylabel('Groupdelay,samples');

F=0:

0.001:

0.4;

g=grpdelay(num1,den1,F,2);%Equalizethepassband

Gd=max(g)-g;

%Designtheallpassdelayequalizer

[num2,den2]=iirgrpdelay(6,F,[0,0.4],Gd);

[GdA,w]=grpdelay(num2,den2,512);

holdon;

plot(w/pi,GdH+GdA,'r');

legend('OriginalFilter','Compensatedfilter');

2.设计巴特沃兹模拟低通滤波器,其滤波器的阶数和3-dB截止频率由键盘输入,程序能根据输入的参数,绘制滤波器的增益响应。

clear;

N=input('TypeintheorderN=');

Wn=input('Typeinthe3-dBcutofffrequencyWn=');%模拟频率

[num,den]=butter(N,Wn,'s');

w=0:

2*Wn;

h=freqs(num,den,w);

plot(w,20*log(abs(h))),grid;

3.已知系统的系统函数为:

用MATLAB进行部分分式展开,并写出展开后的表达式。

%Partial-FractionExpansionofRationalz-Transform

num=[001-0.20.5];

den=[13.21.5-0.81.4];

[r,p,k]=residuez(num,den);

disp('Residues');disp(r')

disp('Poles');disp(p')

disp('Constants');disp(k)

4.设计切比雪夫I型IIR数字高通滤波器,其性能指标为:

通带波纹

,最小阻带衰减

,通带和阻带边缘频率

绘制所设计的滤波器增益响应。

%a4

disp('prewappingisdone,andT=2');

Wp=tan(0.75*pi/2);

Ws=tan(0.5*pi/2);

Rp=0.5;

Rs=43;

[N,Wn]=cheb1ord(Ws,Wp,Rp,Rs,'s');

[b,a]=cheby1(N,Rp,Wn,'s');

[bt,at]=lp2hp(b,a,Wp);

[num,den]=bilinear(bt,at,0.5);

[h,omega]=freqz(num,den);

plot(omega/pi,20*log10(abs(h)));grid;

xlabel('\omega/\pi');ylabel('Gain');

title('TypeIChebyshevHighpassFilter');

clear;%预畸变

Rp=0.5;

Rs=43;

Wp=0.75;

Ws=0.35;

[N,Wp]=cheb1ord(Wp,Ws,Rp,Rs);

[num,den]=cheby1(N,Rp,Wp,'high');

w=0:

pi/1024:

pi;

h=freqz(num,den,w);

subplot(2,1,1);

plot(w/pi,abs(h)),grid;title('Amplitudeinlinearscale')

subplot(2,1,2);

plot(w/pi,20*log10(abs(h))),grid;

title('Amplitudeinlogscale')

 

5.已知复指数序列为:

,绘制30点该序列的实部和虚部。

n=0:

29;

x=0.2*exp((0.4+1i*0.5)*n);

subplot(211);

stem(n,real(x));

xlabel('n');ylabel('realpart');

gridon;

subplot(212);

stem(n,imag(x));

xlabel('n');ylabel('imagpart');

gridon;

6.设计切比雪夫I型模拟低通滤波器,其滤波器的阶数,3-dB截止频率和通带的波纹由键盘输入,程序能根据输入的参数,绘制滤波器的增益响应。

clear;

N=input('滤波器阶数N=');

Wn=input('截止频率Wn=');

Rp=input('通带波纹Rp=');

[num,den]=cheby1(N,Rp,Wn,'s');

w=0:

5*Wn;

h=freqs(num,den,w);

plot(w,20*log10(abs(h))),grid;

xlabel('Frequency,Hz');ylabel('Gain,dB');

 

7.已知系统的系统函数为:

用MATLAB求系统z变换的有理形式,并写出有理形式的表达式。

r=[10.61.8];

p=[-3.22.42.4];

k=0.2;

[num,den]=residuez(r,p,k)

8.设计巴特沃兹IIR数字带通滤波器,其性能指标为:

归一化通带截止频率为

,归一化阻带截止频率为

,通带波纹为0.6dB,最小阻带衰减为35dB。

绘制所设计的滤波器增益响应。

%DesignofIIRButterworthBandpassFilter

Wp=[0.40.6];

Ws=[0.30.7];

Rp=0.6;

Rs=35;

[N,Wn]=buttord(Wp,Ws,Rp,Rs);

[b,a]=butter(N,Wn);

[h,omega]=freqz(b,a,256);

plot(omega/pi,abs(h));grid;

xlabel('\omega/\pi');ylabel('Gain');

title('IIRButterworthBandpassFilter');

disp(N);

disp(Wn);

9.已知指数序列为:

,绘制24点该序列。

n=0:

23;

x=2*0.9.^n;

stem(n,x,'.');

gridon;

ylabel('Amplitude');

xlabel('Timeindex');

 

10.设计椭圆模拟低通滤波器,其滤波器的阶数,3-dB截止频率,通带的波纹和阻带衰减由键盘输入,程序能根据输入的参数,绘制滤波器的增益响应。

clear;

N=input('TypeintheorderN=');

Wn=input('Typeinthe3-dBcutofffrequencyWn=');

Rp=input('TypeinthethepassbandrippleRp=');

Rs=input('TypeinthetheminimumstopbandattenuationRs=');

[num,den]=ellip(N,Rp,Rs,Wn,'s');

w=0:

5*Wn;

h=freqs(num,den,w);

plot(w,20*log10(abs(h))),grid;

xlabel('Frequency,Hz');ylabel('Gain,dB');

11.已知系统的系统函数为:

用MATLAB的impz函数求h[n]的前30个样本值。

clc;

A=[13.21.5-0.81.4];

B=[1-0.20.5];

[H,T]=impz(B,A,30);

disp(H);

stem(T,H);

 

12.已知5阶椭圆IIR数字低通滤波器的性能指标为:

通带截止频率0.35π,通带波纹为0.8dB,最小阻带衰减为35dB。

设计一个10阶全通滤波器对其通带的群延时进行均衡。

绘制低通滤波器和级联滤波器的群延时。

%ellip(N,Ap,Ast,Wp)

%N--->Theorderofthefilter

%Ap-->rippleinthepassband

%Ast->astopbandRsdBdownfromthepeakvalueinthepassband

%Wp-->thepassbandwidth

[be,ae]=ellip(5,0.8,35,0.35);

hellip=dfilt.df2(be,ae);

f=0:

0.001:

0.4;

g=grpdelay(hellip,f,2);

g1=max(g)-g;

[b,a,tau]=iirgrpdelay(10,f,[00.4],g1);

%thefirstparameteraboveistheorderoftheallpass

hallpass=dfilt.df2(b,a);

hoverall=cascade(hallpass,hellip);

hFVT=fvtool([hellip,hoverall]);

set(hFVT,'Filter',[hellip,hoverall]);

legend(hFVT,'LowpassEllipticfilter','Compensatedfilter');

clear;

[num1,den1]=ellip(5,0.8,35,0.35);

[GdH,w]=grpdelay(num1,den1,512);

plot(w/pi,GdH);grid

xlabel('\omega/\pi');ylabel('Groupdelay,samples');

F=0:

0.001:

0.4;

g=grpdelay(num1,den1,F,2);%Equalizethepassband

Gd=max(g)-g;

%Designtheallpassdelayequalizer

[num2,den2]=iirgrpdelay(10,F,[0,0.4],Gd);

[GdA,w]=grpdelay(num2,den2,512);

holdon;

plot(w/pi,GdH+GdA,'r');

legend('OriginalFilter','Compensatedfilter');

 

13.编写4点滑动平均滤波器程序。

原始未受干扰的序列为:

s[n]=3[n(0.8)n],加性噪声信号d[n]为随机序列,幅度0.6,受干扰的序列为:

x[n]=s[n]+d[n],分别绘制长度为40的原始未受干扰的序列,噪声序列和受干扰序列,以及滑动平均滤波器的输出。

%Program2_4

%SignalSmoothingbyaMoving-AverageFilter

R=40;

d=6/5*(rand(1,R)-0.5);

m=0:

1:

R-1;

s=3.*m.*0.8.^m;

x=s+d;

subplot(211);

plot(m,d,'r-',m,s,'b:

',m,x,'m--')

title('Thesequencewithnoise');

ylabel('Amplitude')

legend('d[n]','s[n]','x[n]');

b=ones(4,1)/4;

y=fftfilt(b,x);

subplot(212);

plot(m,s,'r-',m,y,'b--')

title('Theoriginalsequence&theoutputsequence');

legend('s[n]','y[n]');

ylabel('Amplitude')

14.绘制长度为10点的矩形序列的16点离散傅立叶变换样本的幅度和相位。

xn=ones(10,1);

Xk=fft(xn,16);Xkf=abs(Xk);Xkp=angle(Xk);

subplot(211);

stem(0:

15,Xkf,'filled');

xlabel('Timeindex/n');ylabel('Magnitude');

subplot(212);

stem(0:

15,Xkp,'filled');

xlabel('Timeindex/n');ylabel('Phase')

15.已知系统的系统函数为:

用MATLAB的filter函数求h[n]的前20个样本值。

num=[1,-0.2,0.5];

den=[1,3.2,1.5,-0.8,1.4];

x=[1zeros(1,20-1)];

y=filter(num,den,x);

disp('Coefficientsofthepowerseriesexpansion');

disp(y)

stem(y)

16.利用Hermann公式估计FIR低通滤波器的阶数。

该滤波器的性能指标为:

通带截止频率为1500Hz,阻带截止频率为1800Hz,通带波纹为

0.015,阻带波纹为

0.021,抽样频率为5000Hz。

%Program10_1

%EstimationofFIRFilterOrderUsingremezord

%

clear;

fedge=[15001800];%input('Typeinthebandedges=');

mval=[10];%input('Desiredmagnitudevaluesineachband=');

dev=[0.0150.021];%input('Allowabledeviationineachband=');

FT=5000;%input('Typeinthesamplingfrequency=');

[N,fpts,mag,wt]=remezord(fedge,mval,dev,FT);

d=fdesign.lowpass('n,fp,fst',N,0.6,0.72);

design(d);

fprintf('Filterorderis%d\n',N);

17.编写长度为5的中值滤波器程序。

原始未受干扰的序列为:

s[n]=3[n(0.8)n],加性噪声信号d[n]为随机序列,幅度0.6,分别绘制长度为40的受干扰序列,以及中值滤波器的输出。

%Program2_5

%IllustrationofMedianFiltering

%

N=5;

R=40;

b=6/5*(rand(1,R)-0.5);%Generateimpulsenoise

m=0:

R-1;

s=3*m.*(0.8.^m);%Generatesignal

x=s+b;%Impulsenoisecorruptedsignal

y=medfilt1(x,N);%Medianfiltering

subplot(2,1,1)

stem(m,x);axis([050-18]);gridon;

xlabel('n');ylabel('Amplitude');

title('ImpulseNoiseCorruptedSignal');

subplot(2,1,2)

stem(m,y);gridon;

xlabel('n');ylabel('Amplitude');

title('OutputofMedianFilter');

18.已知16点序列x[n]的DFT为:

绘制序列x[n]的实部和虚部。

Xk=(0:

15)/16;xn=ifft(Xk);

xnre=real(xn);

xnim=imag(xn);

subplot(2,1,1);

stem(0:

15,xnre,'.');gridon;

title('Therealpartofthesequence');

subplot(2,1,2);

stem(0:

15,xnim,'.');gridon;

title('Theimaginarypartofthesequence');

19.已知系统的系统函数为:

用MATLAB测试该系统的稳定性。

num=[1-0.20.5];

den=[13.21.50.81.4];

zplane(num,den);

gridon;

20.利用Remez算法设计一个等波纹线性相位FIR低通滤波器。

该滤波器的性能指标为:

通带截止频率为1500Hz,阻带截止频率为1800Hz,通带波纹为

0.015,阻带波纹为

0.021,抽样频率为5000Hz。

%Program10_2

%DesignofEquirippleLinear-PhaseFIRFilters

%

formatlong

fedge=[15001800];

FT=5000;

mval=[10];

dev=[0.0150.021];

[N,fpts,mag,wt]=remezord(fedge,mval,dev,FT);

b=remez(N,fpts,mag,wt);

disp('FIRFilterCoefficients');disp(b)

[h,w]=freqz(b,1,256);

subplot(2,1,1);

plot(w/pi,20*log10(abs(h)));grid;

xlabel('\omega/\pi');ylabel('Gain,dB');

subplot(2,1,2);

plot(w/pi,20*log10(abs(h)));grid;

axis([00.4-0.70.7]);

xlabel('\omega/\pi');ylabel('Gain,dB');

title('detailinpassband')

21.21.已知序列

,计算两个序列的卷积

,并绘制序列

clc;

clear;

x1=[2.23-1.54.2-1.8];

x2=[0.8-11.60.8];

x=conv(x1,x2)%结果在主界面输出

stem(x,'filled');

gridon;

xlabel('Timeindex/n');ylabel('Amplitude');

title('Theoutputconvolution');

22.已知序列x[n]为

,绘制序列x[n]的DFT和DTFT的幅度。

n=0:

15;x=cos(pi*n*0.5);

X=fft(x);

subplot(2,1,1);

stem(n,X,'.');

title('MagnitudeofDFT')

xlabel('n');ylabel('Magnitude')

%circulatingDTFT

k=0:

499;

w=pi/500*k;

X1=x*(exp(-1i*pi/500)).^(n'*k);

magX=abs(X1);

subplot(2,1,2);

plot(w/pi,magX);title('幅度响应');grid;

ylabel('幅度');xlabel('以\pi为单位的频率');

23.已知FIR滤波器的系统函数为:

用MATLAB将系统函数分解为二次多项式之积,并写出各二次多项式的表达式。

clear

P=[2.4,3.2,1.5,0.8,1.4,3.6,5.2];

r=roots(P);%调用函数计算

symsz

s1=simple((z-r

(1))*(z-r

(2)));

d1=simple(s1./z^2)

s2=simple((z-r(3))*(z-r(4)));

d2=simple(s2./z^2)

s3=simple((z-r(5))*(z-r(6)));

d3=simple(s3./z^2)

Q=2.4*d1*d2*d3

 

24.已知FIR数字低通滤波器的性能指标为:

通带截止频率0.35π,阻带截止频率0.45π,通带和阻带波纹=0.01。

设计满足该滤波器的Kaiser’s窗函数,绘制出Kaiser’s窗函数的增益响应。

clear;

fpts=[0.35,0.45];

mag=[1,0];

dev=[0.01,0.01];

[N,Wn,beta,ftype]=kaiserord(fpts,mag,dev);

kw=kaiser(N+1,beta);

b=fir1(N,Wn,kw);

[h,omega]=freqz(b,1,512);

plot(omega/pi,20*log10(abs(h)));grid;

xlabel('\omega/\pi');ylabel('Gain,dB');

25.已知系统的频h响特性为:

绘制该系统的幅频特性和相频特性。

clear

k=500;%numberoffrequencysamplesis500

num=[1-.2.52-.6];%Numeratorcoefficients

den=[13.21.5-.81.4];%Denomin

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 小学教育 > 学科竞赛

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1