第二章 数字信号处理

2018-11-10 09:55

第二章

所用函数:

function [ y,n ] = sigadd( x1,n1,x2,n2 ) %implements y(n)=x1(n)+x2(n) % [y,n]=sigadd(x1,n1,x2,n2)

% y=sum sequence over n,which includes n1 and n2 % x1=first sequence over n1

% x2=second sequence over n2 (n2 can b different from n1)

n=min(min(n1),min(n2)): max(max(n1),max(n2)); %duration of y(n) y1=zeros(1,length(n)); y2=y1; %initialization

y1(find((n>=min(n1)) & (n<=max(n1))==1))=x1; %x1 with duration of y y2(find((n>=min(n2)) & (n<=max(n2))==1))=x2; %x2 with duration of y y=y1 + y2; %sequence addition

function [ y,n ] = sigshift( x,m,n0 ) %implements y(n)=x(n-n0) % [y,n]=sigshift(x,m,n0) %

n=m+n0;y=x;

function [ y,n ] = sigmult( x1,n1,x2,n2 ) %implements y(n)=x1(n)*x2(n) % [y,n]=sigmult(x1,n1,x2,n2)

% y=product sequence over n,which includes n1 and n2 % x1=first sequence over n1

% x2=second sequence over n2(n2 can be different from n1) %

n=min(min(n1),min(n2)) : max(max(n1),max(n2)); %duration of y(n) y1=zeros(1,length(n)); y2=y1; %

y1(find((n>=min(n1)) & (n<=max(n1))==1))=x1; %x1 with duration of y y2(find((n>=min(n2)) & (n<=max(n2))==1))=x2; %x2 with duration of y

y=y1 .* y2; %sequence multiplication

function [ y,ny ] = conv_m( x,nx,h,nh )

%modified convolution routine for signal processing % ------------------------------------------------- % [y,ny]=conv_m(x,nx,h,nh) % [y,ny]=convolution result % [x,nx]=first signal % [h,nh]=second signal %

nyb=nx(1)+nh(1);nye=nx(length(x))+nh(length(h)); ny=[nyb:nye];

y=conv(x,h);

P2.6设x(n)={2,4,-3,-1,-5,4,7},产生并画出下列序列的样本(用stem函数)。

2、x2(n)=4x(4+n)+5x(n+5)+2x(n) 程序: n=[-3:3];

x=[2,4,-3,-1,-5,4,7];

[x21,n21]=sigshift(x,n,-4); [x22,n22]=sigshift(x,n,-5);

[x2,n2]=sigadd(4*x21,n21,5*x22,n22); [x2,n2]=sigadd(x2,n2,2*x,n); stem(n2,x2,'filled'); 结果:

6050403020100-10-20-30-8-6-4-2024

4、x4(n)=2*e^(0.5*n)*x(n)+cos(0.1*pi*n)*x(n+2),-10<=n<=10 程序:

n1=[-10:10]; n2=[-3:3];

x=[2,4,-3,-1,-5,4,7]; y1=exp(0.5*n1); y2=cos(0.1*pi*n1);

[x41,n41]=sigshift(x,n2,-2); [x42,n42]=sigmult(y1,n1,x,n2); [x43,n43]=sigmult(y2,n1,x41,n41); [x4,n4]=sigadd(2*x42,n42,x43,n43); stem(n4,x4,'filled'); 结果:

706050403020100-10-10-8-6-4-20246810

P2.7利用在本章讨论的基本MATLAB信号函数和基本MATLAB信号运算产生下列序列,并用stem函数画出信号样本。

1、x1(n)=3*δ(n+2)+2*δ(n)-δ(n-3)+5*δ(n-7),-5<=n<=15 程序: n=[-5:15]; a=[n==0];

[a1,n1]=sigshift(a,n,-2); [a2,n2]=sigshift(a,n,3); [a3,n3]=sigshift(a,n,7);

[x1,n4]=sigadd(3*a1,n1,2*a,n); [x1,n4]=sigadd(x1,n4,-1*a2,n2); [x1,n4]=sigadd(x1,n4,5*a3,n3); stem(n4,x1,'filled'); 结果:

543210-1-10-50510152025

3、x3(n)=10u(n)-5u(n-5)-10u(n-10)+5u(n-15) 程序: n=[-5:15]; a0=[n>=0]; a1=[(n-5)>=0]; a2=[(n-10)>=0]; a3=[(n-15)>=0];

[x1,n1]=sigadd(10*a0,n,-5*a1,n+5); [x2,n2]=sigadd(x1,n1,-10*a2,n+10); [x,n]=sigadd(x2,n2,5*a3,n+15); stem(n,x,'filled'); 结果:

1050-5-10-15-5051015202530

7、x7(n)=e^(-0.05*n)sin(0.1*pi*n+pi/3),0<=n<=100,对波形形状做出评述。 程序: n=[0:100];

x7=exp(-0.05*n).*sin(0.1*pi*n+pi/3); stem(n,x7,'filled'); 结果:

10.80.60.40.20-0.2-0.4-0.60102030405060708090100

评述:随着n的增大,x7震荡的递减,在n=80时x7几乎为零。

P2.12 程序: n=[-5:45]; u=[n>=0];

%x和h的前26个样本 x=

[0,0,0,0,0,1.0000,0.8000,0.6400,0.5120,0.4096,0.3277,0.2621,0.2097 ,0.1678 ,0.1342 , 0.1074 , 0.0859 , 0.0687,0.0550 , 0.0440 , 0.0352 , 0.0281 , 0.0225 , 0.0180,0.0144 , 0.0115];

h=[0 , 0 ,0 , 0 , 0 , 1.0000 ,-0.9000 , 0.8100 , -0.7290 ,0.6561 , -0.5905 ,0.5314,-0.4783 ,0.4305 ,-0.3874 , 0.3487 , -0.3138 ,0.2824 ,-0.2542 , 0.2288 ,-0.2059 , 0.1853 , -0.1668 ,0.1501,-0.1351 , 0.1216]; %x=((0.8).^n).*u; %h=((-0.9).^n).*u;

%y1=h*x=(8/17*0.8.^n+9/17*(-0.9).^n).*u; y1=(8/17*0.8.^n+9/17*(-0.9).^n).*u; y2=conv(h,x);

%h1(n)=y3(n)-0.8y3(n-1); b=[1]; a=[1,-0.8];

h1=((-0.9).^n).*u; y3=filter(b,a,h1); subplot(1,3,1); stem(n,y1,'filled'); title('解析法'); subplot(1,3,2); stem(n,y2,'filled');


第二章 数字信号处理.doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:人教版五年级数学上册小数的简便计算练习题精选 (105)

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: