实验一 时域离散信号的产生与基本运算
一、实验目的
1、了解常用的时域离散信号及其特点;
2、掌握Matlab 产生常用时域离散信号的方法; 3、掌握时域离散信号简单的基本运算方法;
二、实验内容
1、自己设定参数,分别表示并绘制单位抽样序列、单位阶跃序列、正弦序列、 实指数序列、随机序列;
2、自己设定参数,分别表示并绘制信号移位、信号相加、信号相乘、信号翻转、 信号和、信号积、信号能量。 3、已知信号
2n54n41x(n)60n4
0其他(1) 描绘x(n)序列的波形;
(2) 用延迟的单位脉冲序列及其加权和表示x(n)序列; (3) 描绘一下序列的波形
x1(n)2x(n2),x2(n)2x(n2),x3(n)x(2n)
三、实现步骤
1、自己设定参数,分别表示并绘制单位抽样序列、单位阶跃序列、正弦序列、 实指数序列、随机序列。输出图形如图1所示。
x=zeros(1,10); x(2)=1;
subplot(3,2,1); stem(x,'filled')
axis([0,10,-0.2,1]); title('单位抽样序列');
N=10;
u=ones(1,N); subplot(3,2,2); stem(u,'filled') axis([-10,10,0,1]); title('单位阶跃序列');
x=-20:1:20;
y=sin(0.2*pi.*x+0.5*pi); subplot(3,2,3);
stem(x,y,'filled'); axis([-20,20,-2,2]); title('正弦序列');
n=0:10; a1=1/2; y1=a1.^n;
subplot(3,2,4);
stem(n,y1,'filled');
axis([0,10,0,1]);
title('实指数序列,a=1/2');
n=0:10; a2=2;
y2=a2.^n;
subplot(3,2,5);
stem(n,y2,'filled'); title('实指数序列,a=2');
y=rand(1,20); subplot(3,2,6); stem(y,'filled'); title('随机序列');
图1
2、自己设定参数,分别表示并绘制信号移位、信号相加、信号相乘、信号翻转、 信号和、信号积、信号能量。 信号的移位:
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');
ylabel('x(n)');
subplot(3,1,2),stem(n,x1,'filled');
ylabel('x(n-2)');
subplot(3,1,3),stem(n,x2,'filled'); ylabel('x(n+2)');
信号的相加相乘:
n=-3:20;
x1=cos(2*pi*n/10);
图2
subplot(2,2,1);
stem(n,x1,'filled');title('x(1)');
axis([-4,20,-2,2]); x2=cos(2*pi*n/10); subplot(2,2,2);
stem(n,x2,'filled');title('x(2)');
axis([-4,20,-2,2]); y=x1+x2;
subplot(2,2,3);
stem(n,y,'filled');title('信号相加');
axis([-4,20,-2,2]); y=x1.*x2;
subplot(2,2,4);
stem(n,y,'filled');title('信号相乘'); axis([-4,20,-2,2]);
图3
信号的翻转:
n=-5:5;
x=exp(-0.4*n); x1=fliplr(x); n1=-fliplr(n);
subplot(2,1,1),stem(n,x,'filled');title('x(n)');
subplot(2,1,2),stem(n1,x1,'filled');title('x(-n)');%见下图4
信号和、信号积、信号能量:
x=[1,2,3,4,5,6,7,8,9]; % 和
y1=sum(x) % 积
y2=prod(x)
% 能量
E1=sum(x.*conj(x))
得到: y1 =45 y2 =362880
E1 =285 图4
3、已知信号
2n54n41x(n)60n4
0其他(1) 描绘x(n)序列的波形; (2) 用延迟的单位脉冲序列及其加权和表示x(n)序列; (3) 描绘一下序列的波形
x1(n)2x(n2),x2(n)2x(n2),x3(n)x(2n)
function f=u(t)
f=(t>=0);
subplot(2,1,1) n=-10:10;
y1=(2*n+5).*(u(n+4)-u(n))+6.*(u(n)-u(n-5)); stem(n,y1,'filled') axis([-10,10,-3,6]); title('序列波形'); t=-10:10;
subplot(2,1,2)
y=(-3)*(u(t+4)-u(t+3))+(-1)*(u(t+3)-u(t+2))+(u(t+2)-u(t+1))+3*(u(t+1)-u(t))+6*(u(t)-u(t-1))+
6*(u(t-1)-u(t-2))+6*(u(t-2)-u(t-3))+6*(u(t-3)-u(t-4))+6*(u(t-4)-u(t-5));
stem(t,y,'filled') axis([-10,10,-3,6]);
title('用单位脉冲序列及其加权和表示序列波形');
图5
subplot(2,2,1) t=-10:10;
y=(-3)*(u(t+4)-u(t+3))+(-1)*(u(t+3)-u(t+2))+(u(t+2)-u(t+1))+3*(u(t+1)-u(t))+6*(u(t)-u(t-1))+
6*(u(t-1)-u(t-2))+6*(u(t-2)-u(t-3))+6*(u(t-3)-u(t-4))+6*(u(t-4)-u(t-5));
stem(t,y,'filled') axis([-10,10,-6,12]); title('x(n)');
subplot(2,2,2) t=-10:10;
y=(-3)*(u(t+4)-u(t+3))+(-1)*(u(t+3)-u(t+2))+(u(t+2)-u(t+1))+3*(u(t+1)-u(t))+6*(u(t)-u(t-1))+
6*(u(t-1)-u(t-2))+6*(u(t-2)-u(t-3))+6*(u(t-3)-u(t-4))+6*(u(t-4)-u(t-5));
stem(t+2,2*y,'filled') axis([-10,10,-6,12]); title('2x(n-2)');
subplot(2,2,3) t=-10:10;
y=(-3)*(u(t+4)-u(t+3))+(-1)*(u(t+3)-u(t+2))+(u(t+2)-u(t+1))+3*(u(
t+1)-u(t))+6*(u(t)-u(t-1))+
6*(u(t-1)-u(t-2))+6*(u(t-2)-u(t-3))+6*(u(t-3)-u(t-4))+6*(u(t-4)-u(t-5));
stem(t-2,2*y,'filled') axis([-10,10,-6,12]); title('2x(n+2)');
subplot(2,2,4) t=-10:10;
y=(-3)*(u(t+4)-u(t+3))+(-1)*(u(t+3)-u(t+2))+(u(t+2)-u(t+1))+3*(u(t+1)-u(t))+6*(u(t)-u(t-1))+
6*(u(t-1)-u(t-2))+6*(u(t-2)-u(t-3))+6*(u(t-3)-u(t-4))+6*(u(t-4)-u(t-5));
stem(2-t,y,'filled') axis([-10,10,-6,12]); title('x(2-n)');
图6
因篇幅问题不能全部显示,请点此查看更多更全内容