@数字处理仿真与应用实验一:信号采样、常用离散信号的表示、信号的基本运算:乘累加、卷积
这学期数字处理仿真与应用实验的记录
不多说,进入正题吧~
实验要求
实验名称:信号的表示
程序功能:
1.信号采样
2.常用离散信号的表示
3.信号的基本运算:乘累加、卷积
程序结构:
1.对f(t)=2cos(2pi10t+0.2)+2.5cos(2pi15t+0.5)模拟信号进行采样
2.常用离散信号的表示:单位采样序列、单位阶跃序列、正弦序列、复指数序列
3.信号的基本运算:加、减、乘、乘累加、卷积
实验结果
代码
%---------------------%
%------信号的表示------%
%---------------------%
%程序功能:
%----------1.信号采样
%----------2.常用离散信号的表示
%----------3.信号的基本运算:乘累加、卷积
%程序结构:
%----------1.对f(t)=2*cos(2*pi*10t+0.2)+2.5*cos(2*pi*15t+0.5)模拟信号进行采样
%----------2.常用离散信号的表示:单位采样序列、单位阶跃序列、正弦序列、复指数序列
%----------3.信号的基本运算:加、减、乘、乘累加、卷积
%编程人员:就酱
%编程更新时间:2020年5月6日
clc;
clear all;
close all;
%==信号的采样
A0=2; %V0
A1=2.5; %V1
f0=10;
f1=15;
phi0=0.2;%初相0
phi1=0.5;%初相1
fs=15*f1;%采样频率
Ts=1/fs; %采样间隔
N=100; %离散信号的点数
n=0:N-1;
T=n*Ts;
x=A0*sin(2*pi*f0/fs*n+phi0)+A1*sin(2*pi*f1/fs*n+phi1);
%==显示信号的采样
figure(1)
subplot(311);plot(T,x,'m');grid
xlabel('t(s)');
ylabel('f(t)');
title('模拟信号');
subplot(312);plot(T,x,'m',n*Ts,x,'mo');grid
xlabel('t(s)');
ylabel('f(t)');
title('采样过程');
subplot(313);stem(n,x,'m');grid
xlabel('n');
ylabel('x(n)');
title('离散信号');
figure(2)
%==单位采样序列
subplot(221)
n=-5:10;
Y1=[zeros(1,5),1,zeros(1,10)];
stem(n,Y1,'m');grid
axis([-5,10,0,1]);
title('单位采样序列')
%==单位阶跃序列
subplot(222)
n=-5:10;
Y2=[zeros(1,5),ones(1,11)];
stem(n,Y2,'m');grid
axis([-5,20,0,1]);
title('单位阶跃序列')
%==正弦序列
subplot(223)
n=-5:0.5:10;
Y3=sin(0.5*pi*n);
stem(n,Y3,'m');grid
axis([-5,10,-2,2]);
figure(3);
%==复指数函数
k=-5:20;
f=exp(1i*0.5-0.2).^k;
Xr=real(f);Xi=imag(f)
Xa=abs(f); Xn=angle(f)
subplot(2,2,1), stem(k,Xr,'m'),title('实部');
axis([0,20,-1,1]);
subplot(2,2,3), stem(k,Xi,'m'),title('虚部');
axis([0,20,-1,1]);
subplot(2,2,2), stem(k,Xa,'m'),title('模值');
axis([0,20,-1,1]);
subplot(2,2,4), stem(k,Xn,'m'),title('相角');
axis([0,20,-3,3]);
figure(4)
%==基本运算
subplot(221)
n=-5:10;
V1=Y1+Y2;
stem(n,V1,'m');grid
axis([-5,20,-2,2]);
title('单位采样序列与阶跃序列的加法')
subplot(222)
n=-5:10;
V2=Y1-Y2;
stem(n,V2,'m');grid
axis([-5,20,-2,2]);
title('单位采样序列与阶跃序列的减法')
subplot(223)
n=-5:10;
V3=Y1.*Y2;
stem(n,V3,'m');grid
axis([-5,20,-2,2]);
title('单位采样序列与阶跃序列的乘法')
V3=prod(Y1);
fprintf('Y1的乘累加值为:%d\n',V3);
V4=prod(Y2);
fprintf('Y2的乘累加值为:%d\n',V4);
subplot(224)
n=-10:20;
V5=conv(Y1,Y2);
stem(n,V5,'m');grid
axis([-5,20,-2,2]);
title('单位采样序列与阶跃序列的卷积')