简单的matlab信号仿真

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

实验1 连续时间信号和离散信号的实现
实验内容与方法
一、验证性试验
1、生成直流信号f(t)=6
MA TLAB程序代码:
t = -10:0.01:10;
a1 = 6;
subplot(3,3,1)
plot(t,a1,'b');
title('直流信号');
xlabel('时间(t)');ylabel('幅值(f)')
2、生成正弦交流信号f(t)=sin(wt+φ)
MA TLAB程序代码:
t = 0:0.01:1;
f = sym('sin(2*pi*t)');
subplot(3,3,2)
ezplot(f,[0,1]);
title('正弦交流信号');
xlabel('时间(t)');ylabel('幅值(f)')
3、生成单位阶跃信号f(t)=ε(t)
MA TLAB程序代码:
t0=0;t1=-1;t2=3;
dt=0.01;
t=t1:dt:-t0;
n=length(t);
t3=-t0:dt:t2;
n3=length(t3);
u=zeros(1,n);
u3=ones(1,n3);
subplot(3,3,3)
plot(t,u);
hold on;
plot(t3,u3);
plot([-t0,-t0],[0,1]);
hold off;
axis([t1,t2,-0.2,1.5]);
xlabel('时间(t)');ylabel('幅值(f)');title('单位阶跃信号')
4、生成单位冲激信号f(t)=δ(t)
MA TLAB程序代码:
t0=0;t1=-1;t2=5;
dt=0.1;
t=t1:dt:t2;
n=length(t);
x=zeros(1,n);
x(1,(t0-t1)/dt+1)=1/dt;
subplot(3,3,4)
stairs(t,x);
axis([t1,t2,0,1/dt]);
xlabel('时间(t)');ylabel('幅值(f)');title('单位冲激信号')
5、生成周期方波信号
MA TLAB程序代码:
t=(0:0.0001:1);
y=square(2*pi*15*t);
subplot(3,3,5)
plot(t,y);axis([0,1,-1.5,1.5]);
xlabel('时间(t)');ylabel('幅值(f)');title('周期方波信号')
6、生成三角波信号
MA TLAB程序代码:
t=(-3:0.0001:5);
y=tripuls(t,4,0.5);
subplot(3,3,6)
plot(t,y);
xlabel('时间(t)');ylabel('幅值(f)');title('三角波信号')
7、生成正弦序列信号
MA TLAB程序代码:
k1=-20;k2=20;
k=k1:k2;
f=sin(k*pi/6);
subplot(3,3,7)
stem(k,f,'filled');
xlabel('时间(t)');ylabel('幅值(f)');title('正弦序列')
8、生成单位斜波序列信号
MA TLAB程序代码:
k1=-20;k2=20;k0=0;
n=[k1:k2];
if k0>=k2
x=zeros(1,length(n));
elseif (k0<k2)&(k0>k1)
x=[zeros(1,k0-k1),[0:k2-k0]];
else
x=(k1-k0)+[0:k2-k1];
end
subplot(3,3,8)
stem(n,x);
xlabel('时间(t)');ylabel('幅值(f)');title('单位斜波序列')
9、生成幅值调制序列信号
MA TLAB程序代码:
n=0:100;
m=0.4;fH=0.1;fL=0.01;
xH=sin(2*pi*fH*n);
xL=sin(2*pi*fL*n);
y=(1+m*xL).*xH;
subplot(3,3,9)
stem(n,y);grid;
xlabel('时间(k)');ylabel('幅值f(k)');title('幅值调制序列')
10、生成复指数信号y(t)=e^(-at+bjt)
MA TLAB程序代码:
t=0:0.01:3;a=-3;b=4;z=exp((a+i*b)*t);
subplot(2,2,1);
plot(t,real(z)),title('实部'):xlabel('时间(t)');ylabel('幅值(f)'); subplot(2,2,2);
plot(t,imag(z)),title('虚部'):xlabel('时间(t)');ylabel('幅值'); subplot(2,2,3);
plot(t,abs(z)),title('模'):xlabel('时间(t)');ylabel('幅值'); subplot(2,2,4);
plot(t,real(z)),title('相角'):xlabel('时间(t)');ylabel('幅值')
二、程序设计实验
①a=3;
x=-10:0.01:10;
y=(1-2*abs(x))/a;
subplot(3,3,1)
plot(x,y,'b')
axis([-12,12,-10,5]);
xlabel('x');ylabel('y');title('(1-2*abs(x))/a')
②t = 0:0.01:6*pi;
f = sym('cos(3*t)+sin(2*t)');
subplot(3,3,2)
ezplot(f,[0,6*pi]);
title('信号');
xlabel('时间(t)');ylabel('幅值(f)')
③t0=-5;t1=-10;t2=5;
dt=0.01;
t=t1:dt:t0;
n=length(t);
t3=t0:dt:t2;
n3=length(t3);
u=zeros(1,n);
u3=ones(1,n3);
subplot(3,3,3)
plot(t,u);
hold on;
plot(t3,u3);
plot([t0,t0],[0,1]);
hold off;
axis([t1,t2,-0.2,1.2]);
xlabel('时间(t)');ylabel('幅值(f)');title('u(t+5)')
④k1=-20;k2=20;
k=k1:k2;
f=cos(5*k)+sin(4*k);
subplot(3,3,7)
stem(k,f,'filled');
xlabel('时间(k)');ylabel('幅值f(k)');title('信号4')
⑤x=0:0.01:3;z=5*exp(-x);
subplot(2,2,1);
plot(x,real(z)),title('信号5'):xlabel('时间(x)');ylabel('幅值(f)')
⑥k0=0;k1=-1;k2=10;
dk=1;
k=k1:dk:k2;
n=length(k);
x=zeros(1,n);
x(1,(k0-k1)/dk+1)=1/dk;
subplot(3,3,4)
stairs(k+5,x);
axis([k1,k2,0,1/dk]);
xlabel('时间(k)');ylabel('幅值(f)');title('信号6')
⑦t0=-5;t1=-6;t2=0;
t=t1:t0-1;
n=length(t);
t3=t0:t2;
n3=length(t3);
u=zeros(1,n);
u3=ones(1,n3);
subplot(3,3,7)
stem(t,u,'filled');
hold on;
stem(t3,u3,'filled');
hold off;
axis([t1,t2,-0.2,1.5]);
xlabel('时间(t)');ylabel('幅值(f)');title('信号7');。

相关文档
最新文档