数字信号处理Word下载.doc
《数字信号处理Word下载.doc》由会员分享,可在线阅读,更多相关《数字信号处理Word下载.doc(30页珍藏版)》请在冰点文库上搜索。
(1)程序代码
“.m”文件内容如下:
N=12;
M=4;
n=[0:
2*N-1];
Xm=sin(2*pi*M*n/N);
subplot(4,2,1);
stem(n,Xm);
xlabel('
n'
);
ylabel('
x4(n)'
M=5;
subplot(4,2,3);
x5(n)'
M=7;
subplot(4,2,5);
x7(n)'
M=10;
subplot(4,2,7);
x10(n)'
subplot(4,2,2);
plot(n,Xm);
subplot(4,2,4);
subplot(4,2,6);
subplot(4,2,8);
仿真图如下
由上图可看出,当M=4时,最小整数周期T=3;
M=5时,T=12;
M=7时,T=12;
M=10时,T=6;
所以当M=4时,得到的最小整数周期为3。
题中信号x(n)=sin(2πMn/N)的频率w=2πM/N,由公式得周期T=2kπ/w,有T=kN/M(k=1,2,...)。
当N/M为正整数时,最小周期T=N/M;
当N/M为有理数时,不管M>
N或者M<
N,都有最小周期T=N;
当N/M为无理数时,该序列不是周期序列。
(2)程序代码
“.m”文件内容如下:
k=1;
9];
w=2*pi*k/5;
x=sin(w*n);
subplot(2,2,1);
stem(n,x);
x1(n)'
k=2;
subplot(2,2,2);
x2(n)'
k=4;
subplot(2,2,3);
k=6;
subplot(2,2,4);
x6(n)'
仿真图如下
由上图可看出有三种不同的信号,当k=1和k=6的仿真结果是一样的,k=2与k=4是另外二种。
为什么不同的ωk值可以得到相同的信号呢?
因为ωk=2πk/5,又T=2π/ωk,得信号的最小周期Tmin=5。
当k=1和k=6时,两个信号刚好相差一个周期,可看做两个信号的周期是一样的,所以两个信号相同。
Experiment1.2DiscreteTimeDomainSystemAnalysis
(1)Calculationofdiscrete-timeconvolution
(2)Determinethelinearityandshift-invarianceofthesystems.
2.Content
2.1Calculationofdiscrete-timeconvolution
(1)Calculatetheconvolutionsofthefollowingsignalswithconv.Drawthecurvesofx(n),h(n)andy(n)(x(n)*h(n))respectively.
(2)Considerx(n)=0.5nu(n)
h(n)=u(n)
Ifcalculatey(n)=x(n)*h(n)withconv,theproblemofinfinitelengthsofx(n)andh(n)shouldbesolved.Savethex(n)intherangeof0≤n≤24invectorx,theh(n)intherangeof0≤n≤14invectorh,theresultconv(h,x)invectory.Drawthey(n)withstem,comparingwith0.5nu(n)*u(n),pleasepointoutwhichvaluesaretrueandwhichvaluesarefalse.
2.2Determinethelinearityandshift-invarianceofthesystems
Considerthefollowingthreesystems
System1:
w(n)=x(n)-x(n-1)-x(n-2)
System2:
y(n)=cos(x(n))
System3:
z(n)=nx(n)
wherex(n)istheinput,w(n),y(n)andz(n)aretheoutputs.
(1)Considerthethreeinputsignals
x1(n)=δ(n)
x2(n)=δ(n-1)
x3(n)=δ(n)+2δ(n-1)
theoutputofsystem1arestoredrespectivelyinvectorsw1,w2andw3(0≤n≤5).Drawthecurvesofw1,w2,andw1+2w2inonegraph.
(2)Repeat
(1)withsystem2.
(3)Repeat
(1)withsystem3.
(4)Whichofthesystemsisthelinearandshiftinvariantsystem?
(1)GivetheMfilesandthefigures.
(2)Answerthequestion.
1.2.1
(1)
代码如下:
n=0:
14;
x=[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1];
h=0.8.^n;
[y]=conv(x,h)
ny=length(y);
n1=0:
ny-1;
subplot(3,1,1);
x(n)'
subplot(3,1,2);
stem(n,h);
h(n)'
subplot(3,1,3);
stem(n,y);
y(n)'
仿真图如下:
程序代码如下:
9;
x=[1,1,1,1,1,1,1,1,1,1];
19;
h=0.5*sin(0.5*n1);
[y]=conv(x,h);
n2=0:
stem(n1,h);
subplot(3,1,3);
stem(n2,y);
(2)
x(n)=0.5nu(n),0≤n≤24;
h(n)=u(n),0≤n≤14;
计算其卷积为y(n)。
程序如下:
24;
x=0.5*n;
h=[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1];
0.5nu(n)*u(n)的程序如下:
200;
h=ones(1,201);
问题:
与0.5nu(n)*u(n)作比较,指出上图中哪些是错误的,哪些是正确的?
答:
n越大则卷积的结果越准确,n的数量取得较少时结果会有一定的误差。
图中y(n)在0≤n≤15时(前部分)是正确的,而在后部分16≤n≤39之间出现了一定的误差。
1.2.2
(1)System1:
程序如下:
Function[x,n]=impseq(n0,n1,n2)
n=[n1:
n2];
x=[(n-n0)==0];
End
5;
w1=impseq(0,0,5)-impseq(1,0,5)-impseq(2,0,5);
w2=impseq(1,0,5)-impseq(2,0,5)-impseq(3,0,5);
w3=impseq(0,0,5)+2*impseq(1,0,5)-impseq(1,0,5)-2*impseq(2,0,5)-impseq(2,0,5)-2*impseq(3,0,5);
subplot(4,1,1);
stem(n,w1);
w1'
subplot(4,1,2);
stem(n,w2);
w2'
subplot(4,1,3);
stem(n,w3);
w3'
subplot(4,1,4);
stem(n,w1+2*w2);
w1+2*w2'
(2)System2:
y(n)=cos(x(n))
程序如下:
x1=impseq(0,0,5);
x2=impseq(1,0,5);
x3=impseq(0,0,5)+2*impseq(1,0,5);
y1=cos(double(x1));
y2=cos(double(x2));
y3=cos(double(x3));
stem(n,y1);
y1(n)'
stem(n,y2);
y2(n)'
stem(n,y1+2*y2);
y3(n)'
(3)System3:
程序如下:
z1=n*diag(x1);
z2=n*diag(x2);
z3=n*diag(x3);
stem(n,z1);
z1'
stem(n,z2);
z2'
stem(n,z3);
z3'
stem(n,z1+2*z2);
z1+2*z2'
哪些系统是线性的?
哪些不是?
System1是线性移不变系统,System2是非线性移不变系统,System3是线性移变系统。
Experiment1.3Frequencydomainsystemanalysis
1.Purposes
(1)Befamiliarwiththefrequencycharacteristicsofdiscrete-timesystems.
(2)Learntoanalyzesystemsinanalogdomainanddigitaldomainbyacomputer.
[1]ConsiderthesystemH(Z)=Z/(Z-A),analyzingtheamplitudespectrumandthephase
spectrumofintherange0≤ω≤4πwhen
(1)A=0.5;
(2)A=-0.5;
(3)A=0
[2]AnalyzingtheamplitudespectrumofH(jΩ)intherange0≤Ω≤2π.
[3]DesigntheDFandanalyzetheamplitudespectrumintherange0≤ω≤2π.
(1)Theprototypeisasabove,assumethesamplingintervalTsis0.5s,determinethedigital
filterH1(z)withimpulseinvariancemethod.
(2)AssumethesamplingintervalTsis0.1s.Repeat
(1)andobtainthedigitalfilterH2(z).
(3)PlotH1(z)andH2(z)inthesamegraphwithsubplot.
[1]CalculateH1(z)andH2(z);
[2]GivetheMfilesandthefigures.
1.3.2
(1)systemH(Z)=Z/(Z-A),其相位的ω取值范围0≤ω≤4π。
A=0.5;
k=0:
2000;
w=(pi/500)*k;
H=exp(j*w)./(exp(j*w)-A);
magH=abs(H);
angH=angle(H);
subplot(3,2,1);
plot(w/pi,angH);
title('
相位响应'
相位/\pi'
以\pi为单位的频率'
subplot(3,2,2);
plot(w/pi,magH);
幅度响应'
幅度/\pi'
A=-0.5;
subplot(3,2,3);
subplot(3,2,4);
A=0;
subplot(3,2,5);
subplot(3,2,6);
(2),分析其振幅特性H(jΩ),其中Ω的取值范围0≤Ω≤2π。
1000;
H=2./(3+4*(j*w)+(j*w).^2);
subplot(1,1,1);
plot(w,magH);
(3)H1(z)为T=0.5s时的输出,H2(z)为T=0.1s时的输出,两函数的幅度响应和相位相应
程序如下:
1:
w=pi*k/100;
H1=exp(j*w)./(exp(j*w)-exp(-0.5))-exp(j*w)./(exp(j*w)-exp(-3*0.5));
H2=exp(j*w)./(exp(j*w)-exp(-0.1))-exp(j*w)./(exp(j*w)-exp(-3*0.1));
magH1=abs(H1);
magH2=abs(H2);
bh1=angle(H1);
bh2=angle(H2);
plot(w/pi,magH1);
幅度响应H1(Z)'
以/pi为单位的频率'
幅度'
subplot(3,2,3);
plot(w/pi,bh1);
相位响应H1(Z)'
相位/pi'
subplot(3,2,2);
plot(w/pi,magH2);
幅度响应H2(Z)'
subplot(3,2,4);
plot(w/pi,bh2);
相位响应H2(Z)'
H3=2*(3+4*j*w-w.*w).^-1;
magH3=abs(H3);
angH3=angle(H3);
subplot(3,2,5);
plot(w/pi,magH3);
模拟滤波器幅度特性'
grid;
以π为单位的频率'
subplot(3,2,6);
plot(w/pi,angH3);
模拟滤波器相位特性'
相位/\pi'
计算出H1(z)andH2(z).
根据设计出来的滤波器,所得函数
H1(z)=0.164*z/(z^2-1.646*z+0.6706)
H2(z)=0.384*z/(z^2-0.83*z+0