基于matlab的离散系统时域分析实验,《信号与系统》 实验一 信号的时域分析及Matlab实现...

实验一 信号的时域分析及Matlab实现

参考文章

题目

题目1代码实现

讲解

sinc(t)

Sa(t)

时移、翻转、展缩

subs(s,old,new)

ezplot() 绘画符号函数

题目2代码实现

讲解

题目3代码实现

新建函数

单位抽样序列

单位阶跃序列

离散信号的运算

参考文章

信号与系统实验指导

题目

4b45ad1b346556ff5afcd753e4c53192.png

题目1代码实现

syms t;

f=sym('sin(t)/t'); %定义符号函数 f(t)=sin(t)/t

f1=subs(f,t,(-3)*t+5); %对 f 进行移位

subplot(2,1,1);ezplot(f,[-8,8]);grid on;% ezplot 是符号函数绘图命令

subplot(2,1,2);ezplot(f1,[-8,8,-0.3,1.1]);grid on;

运行结果

010edc96b070cc8ef9d8aa8bd9f89063.png

讲解

sinc(t)

be2efb5e9ac746d2159fc04d9bda3a85.png

Sa(t)

56b45d1e83e9c8e38f7582249b9e35b9.png

所以sinc (t/pi) = Sa(t)

时移、翻转、展缩

由 f (t)到

f ( − a t + b ) ( a > 0 ) f(-at+b)(a>0)f(−at+b)(a>0)

所用函数

subs(s,old,new)

returns a copy of s replacing all occurrences of old with new, and then evaluating s.

例:已知 f (t) = sin(t) / t ,试通过翻转、移位、展缩由 f (t)的波形得到 f (-2t + 3) 的波形。

syms t;

f=sym('sin(t)/t'); %定义符号函数 f(t)=sin(t)/t

f1=subs(f,t,t+3); %对 f 进行移位

f2=subs(f1,t,2*t); %对 f1 进行展缩

f3=subs(f2,t,-t); %对 f2 进行翻转

可以一步到位

syms t;

f=sym('sin(t)/t'); %定义符号函数 f(t)=sin(t)/t

f3 = subs(f, t, -2t+3);

ezplot() 绘画符号函数

ezplot(fun2,[xmin,xmax,ymin,ymax])

plots fun2(x,y) = 0 over xmin < x < xmax and ymin < y < ymax.

一般搭配使用

subplot(2,1,1);%divides the current figure into an m-by-n grid and creates an axes for a subplot in the position specified by p

ezplot(f,[-8,8,-0.3,1.1]);

grid on;%画网格与否

题目2代码实现

t=(-10:0.01:5);

f1= sin(2*pi*t)+exp(-3*t);

f2= sin(3*pi*t)-exp(-5*t);

f3= sin(2*pi*t).*exp(-3*t);

subplot(2,2,1);plot(t,f1);grid on;

subplot(2,2,2);plot(t,f2);grid on;

subplot(2,2,3);plot(t,f3);grid on;

0a3d7cc84664305ecd30f343fb537657.png

讲解

f3= sin(2pit).exp(-3t);

如果你使用f3= sin(2pit)exp(-3t);而没加 .,建议学习一下matlab中数组乘法与矩阵乘法的区别

题目3代码实现

[x1,n]=delta(3,-4,10);

[x2,n]=step_seq(-2,-4,10);

subplot(2,2,1);

stem(n,x1+x2);

[x1,n]=delta(-3,-5,10);

[x2,n]=step_seq(2,-5,10);

subplot(2,2,2);

stem(n,x1-x2);

[x1,n]=delta(3,-5,10);

[x2,n]=step_seq(-2,-5,10);

subplot(2,2,3);

stem(n,x1.*x2);

9d0020878f815782c8a6f4c2c9e490e4.png

新建函数

96424975d959c94388aa145d325ebf46.png

在空白处右键–》新建函数–》函数

修改函数名与文件名一致,最好保存在同一文件夹,到时候在同一个文件夹的其他 .m文件直接引用就ok

单位抽样序列

δ ( n − n 0 ) = { 1 , n = n 0 0 , n ≠ n 0 \delta(n-n0)=\left\{\begin{array}{lc}1,&n=n0\\0,&n\neq n0\end{array}\right.δ(n−n0)={1,0,​n=n0n​=n0​

先根据上面新建一个函数,然后先定义delta函数,并保存。

function[x,n]=delta(n0,n1 ,n2)

n=[n1:n2];

x=[(n-n0)==0];

然后在主的.m文件

[x,n]=delta(3,-1,10);

stem(n,x);

a20adbb332f1b9a41f027c5f092a42ec.png

单位阶跃序列

u ( n − n 0 ) = { 1 , n > = n 0 0 , n < n 0 u(n-n0)=\left\{\begin{array}{lc}1,&n>=n0\\0,&nu(n−n0)={1,0,​n>=n0n

先根据上面新建一个函数,然后先定义step_seq函数,并保存。

function[x,n]=step_seq(n0, n1, n2)

n=[n1:n2];

x=[(n-n0)>=0];

然后在主的.m文件

[x,n]=step_seq(3,-1,10);

stem(n,x);

d9f4c6fa442f0323c23e1b32afb0b420.png

离散信号的运算

n一样,x不一样,在stem里面加

[x1,n]=delta(3,-4,10);

[x2,n]=step_seq(-2,-4,10);

stem(n,x1+x2);

如果是乘法,那么在**“*”前加“.”**

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值