常见序列,运算,系统响应

1. 常用序列

单位脉冲序列

eg1:
n1=-5:5; x1=[(n1==0)]; stem(n1,x1); title('单位脉冲序列'); axis([-5,5,0,1]);

eg2:
x=[1 zeros(1.N-1)];

单位阶跃序列

n1=-5:5;
x1=[(n1>=0)];
stem(n1,x1);
title('单位脉冲序列');
axis([-5,5,0,1]);

 正余弦序列

n=0:40;
x1=3*cos(0.1*pi*n+pi/3);
x2=2*sin(0.2*pi*n);
subplot(2,1,1);
stem(n,x1);title('余弦序列');
subplot(2,1,2);
stem(n,x2);title('正弦序列');

 指数序列

clear;
n1=0:40;
x1=exp((0.1+(pi/6)*1i)*n1);
subplot(2,1,1);
stem(n1,real(x1));title('复指数序列');
ylabel('实部');
subplot(2,1,2);
stem(n1,imag(x1));
ylabel('虚部');

 2.序列的基本运算

序列的移位

clear;
n=-3:10;k0=3;k1=-3;
x=cos(2*pi*n/10);
x1=cos(2*pi*(n-k0)/10);
x2=cos(2*pi*(n-k1)/10);
subplot(3,1,1),stem(n,x,'filled','k');
ylabel('x(n)');
subplot(3,1,2),stem(n,x1,'filled','k');
ylabel('x(n-2)');
subplot(3,1,3),stem(n,x2,'filled','k');
ylabel('x(n+2)');

 求和,乘积

clear;
x1=[0,1,2,3,4,3,2,1,0];ns1=-2;
x2=[2,2,0,0,0,-2,-2];ns2=2;
nf1=ns1+length(x1)-1
nf2=ns2+length(x2)-1
ny=min(ns1,ns2):max(nf1,nf2);
xa1=zeros(1,length(ny));xa2=xa1;
xa1(find((ny>=ns1)&(ny<=nf1)==1))=x1;
xa2(find((ny>=ns2)&(ny<=nf2)==1))=x2;
ya=xa1+xa2
yp=xa1.*xa2

 subplot(4,1,1),stem(ny,xa1,'.')
  subplot(4,1,2),stem(ny,xa2,'.')
  line([ny(1),ny(end)],[0,0])
  subplot(4,1,3),stem(ny,ya,'.')
  line([ny(1),ny(end)],[0,0])
  subplot(4,1,4),stem(ny,yp,'.')
  line([ny(1),ny(end)],[0,0])

 

序列反转

clear;
n=-5:5;
x=exp(-0.4*n);
x1=fliplr(x);
n1=-fliplr(n);
subplot(1,2,1),stem(n,x,'filled','k');title('x(n)');
subplot(1,2,2),stem(n1,x1,'filled','k');title('x(n)');

 

 3.系统响应的求解

冲激,阶跃

y(n)+0.5y(n-1)=x(n)+2x(n-2)

clear;
a=[1,0.5,0];b=[1,0,2];
n=16;
hn=impz(b,a,n);
gn=dstep(b,a,n);
x=1:16
subplot(2,1,1),stem(x,hn,'filled','k');title('冲激响应');
subplot(2,1,2),stem(x,gn,'filled','k');title('阶跃响应');

 

 conv卷积运算

u = [1 1 1];
v = [1 1 0 0 0 1 1];
w = conv(u,v)
w = 1×9

     1     2     2     1     0     1     2     2     1

 

posted @ 2021-03-22 09:39  为红颜  阅读(687)  评论(0编辑  收藏  举报