Advertisement

MATLAB信号与系统分析(一)——连续时间信号与系统的时域分析

阅读量:

一、连续时间信号的表示:

1、向量表示法:

在MATLAB中,是用连续信号在等时间间隔点的样值来近似表示连续信号,当取样时间间隔足够小时,这些离散的样值就能较好地近似出连续信号。

对于连续时间信号f(t),一般是用两个行向量f和t来表示。t=t1:p:t2 ,t1 表示的是信号的起始时间,t2为终止时间,p为时间的间隔。而f为连续时间f(t)在向量t所定义的时间范围内对应的样值。

2、符号运算表示法:

使用sym定义变量,然后进行表示。

Eg:分别采用上述两种方法画出抽样信号:

image
复制代码
    clear all;
    t101.510取点数比较少,图形会比较失真
    ft;
    subplot(221),plot(t,f)
    
    t100.110取点数比较多,图形会比较接近
    ft;
    subplot(222),plot(t,f)
    
    f'sin(t)/t'采用符号方法
    subplot(2231010])
    t31003pi;
    
    ft直接用malab中的函数
    subplot(224

二、一些常用信号的表示:

1、单位阶跃信号:

(1)利用符号函数maple中的内核函数Heaviside

(2)利用自编函数Heaviside(t)

复制代码
    Heaviside(t)
    f0

(3)利用符号函数来生成单位阶跃函数

image
复制代码
110;
    f20.5;
    plot(t,f);
    axis([551.21.2
image
复制代码
    clear all
    32u(t)
    subplot(221);
    syms t
    f32heaviside(t);
    ezplot(f,[33pi])
    axis([551.21.2]);
    title('u(t+3)-2u(t)');
    
    32u(t)
    subplot(222);
    t50.015;
    f32Heaviside(t);
    plot(t,f);
    axis([551.21.2]);
    title('u(t+3)-2u(t)')
    
    利用符号函数来实现单位阶跃信号
    subplot(223);
    t50.055;
    fsign(t);
    ff1212f;
    plot(t,ff);
    axis([550.11.1]);
    title('u(t)')
    
    32u(t)
    subplot(224);
    t50.015;
    f1212321212sign(t));
    plot(t,f),axis([551.21.2'u(t+3)-2u(t)'

PS:由于自己生成的阶跃函数定义u(0)=0,而自带的定义为u(0)=1,所以会出现这种图形没有连接起来的问题。

image

2、MATLAB信号处理工具箱提供的连续信号:

(1)使用MATLAB自带函数生成:

复制代码
    t)
    subplot(241);
    A1;
    a0.4;
    t00.0110;
    ftt);
    plot(t,ft);
    title('指数信号'要放在plot后面
    grid on
    
    phi)
    subplot(242);
    A1;
    w02pi;
    phi6;
    t00.0018;
    ftphi);
    plot(t,ft);
    title('正弦信号');
    grid on;
    
    t
    subplot(243);
    t31003pi;
    ftpi);
    plot(t,ft);
    title('抽样函数信号');
    grid on;
    
    0点左右对称的矩形波信号
    subplot(244);
    t00.0014;
    T1;
    ft22T);
    plot(t,ft);
    axis([150.51.5要放在plot后面
    title('矩形脉冲信号');
    grid on;
    
    1)的周期性方波信号,duty表示占空比
    subplot(234);
    t0.06250.0010.0625;
    ft23075);
    plot(t,ft);
    axis([0.06250.06251.51.5]);   
    title('频率为30赫兹的周期性方波信号');
    grid on;
    
    tripuls(t,width,skew)用以产生一个最大幅度为1,宽度为width,斜度为skew的三角波信号。
    2的范围。
    1和1之间的值,它表示最大幅度1出现所对应的横坐标位置。
    2)×skew的横坐标位置
    subplot(235);
    t30.0013;
    ft40.5);
    plot(t,ft);
    axis([330.51.5]);   
    title('三角波脉冲信号');
    grid on;
    
    1的周期性三角波信号(又称锯齿波信号)。
    width表示最大幅度出现的位置
    subplot(236);
    t5105pi;
    ft0.5);
    plot(t,ft);
    axis([16161.51.5]);   
    title('周期性三角波信号');
    grid on;
image

(2)信号工具函数

%一般周期性脉冲信号y=pulstran(t,d,'func',p1,p2,...)
%t制定pulstran的横坐标范围,向量d用于指定周期性的偏移量(即各个周期的中心点)
%整个pulstran函数的返回值实际上就相当于y=func(t-d(1))+func(t-d(2))+......
%p1,p2...是需要传送给func函数的额外输入参数值(除去时间变量t外),例如rectpuls需要width这个额外参数等

复制代码
    'func',p1,p2,...)
    t制定pulstran的横坐标范围,向量d用于指定周期性的偏移量(即各个周期的中心点)
    12......
    p1,p2...是需要传送给func函数的额外输入参数值(除去时间变量t外),例如rectpuls需要width这个额外参数等
    clear all;
    subplot(121);
    t0.50.0011.5;
    d00.51;
    y'rectpuls'0.1周期性矩形信号
    plot(t,y);
    axis([0.11.10.11.1]);
    title('周期性矩形信号')   
    grid on
    
    周期三角波信号
    subplot(122);
    t0.20.0011.2;
    d0121;
    y'tripuls'0.11);
    plot(t,y);
    axis([0.11.10.11.1]);
    title('周期性三角波信号');
    grid on;
image

3、复指数信号

image

例子:image

复制代码
    实现方法一:
    
    fuction fexp(d,w,t1,t2,a)
    绘制复指数信号时域波形程序
    d:复指数信号复频率实部
    w:复指数信号复频率虚部
    t1:绘制波形的起始时间
    t2:绘制波形的终止时间
    a:复指数信号的幅度
    clear all
    figure(1);
    fexp(040152);
    
    实现方法二:
    t00.0115;
    a04;
    z2t);
    figure(2)
    subplot(221'实部')
    subplot(223'虚部') 
    subplot(222'模')
    subplot(224'相角'
image

三、连续信号的时域运算、时域变换

1、利用符号运算实现连续信号的时域变换

(1)相加:

复制代码
    f2
    ezplot(s)

(2)相乘:

复制代码
    f2
    ezplot(s)

(3)移位:

复制代码
    t0)
    yt0)
    ezplot(y)

(4)反折:

复制代码
    t)
    ezplot(y)

(5)尺度变换:

复制代码
    t)
    ezplot(y)

(6)倒相

复制代码
    f
    ezplot(y)
image
复制代码
    clear all
    syms t
    '(t/2+1)*(heaviside(t+2)-heaviside(t-2))')
    
    f2122));
    subplot(23133'f(t)')
    
    y12)
    subplot(23251'f(t+2)')
    
    y22)
    subplot(23315'f(t-2)')
    
    y3t)
    subplot(23433'f(-t)')
    
    y42t)
    subplot(23522'f(2*t)')
    
    y5f
    subplot(23633'-f(t)'
image

四、连续系统的冲激响应、阶跃响应

image

1、冲激响应:

复制代码
    limpulse(b,a)
    
    impulse(b,a,t)
    
    impulse(b,a,t1:p:t2)
    
    y

2、阶跃响应

复制代码
    step(b,a)
    step(b,a,t)
    step(b,a,t1:p:t2)
    y

其中:

image
image
复制代码
    clear all;
    a156];
    b302];
    
    冲击响应
    figure(1)
    subplot(221),impulse(b,a)
    subplot(2225绘制0~5范围内冲激响应的时域波形
    subplot(22310.12绘制1~2范围内,步长为0.1的冲激响应的时域波形
    y110.13给出数值解
    subplot(22410.13,y1)
    
    阶跃响应
    figure(2)
    subplot(221),step(b,a)
    subplot(2225)
    subplot(22310.12)
    y210.13);
    subplot(22410.13

image image

五、求LTI连续系统的响应

1、零输入响应:

复制代码
    0

2、零状态响应:

复制代码
    Lsim(sys,X,t)
    Lsim(b,a,X,t)
    Lsim(A,B,C,D,X,t)

3、全响应:

复制代码
    0

其中:

微分方程系统函数对象的生成函数:sys=tf(b,a)

微分方程的状态方程系数生成函数: [A,B,C,D]=tf2ss(b,a)

image

4、例子:

image
复制代码
    clear all;
    a132];
    b13];
    t00.0110;
    x3t);
    rc21];
    systf(b,a)
    [A,B,C,D]tf2ss(b,a)
    figure(1)
    subplot(311零输入响应
    subplot(312零状态响应
    subplot(313

结果:

复制代码
     
      s 3
      s232
     
    Continuoustime transfer function.
    
    
    A 3210
    
    
    B 10
    
    
    C 13
    
    
    D 0
image

六、两个信号的卷积:

image
image

1、自编卷积函数:

复制代码
    gggfconv(f1,f2,t1,t2)    
    d');计算序列f1和f2的卷积和
    fd; 
    ts11计算序列f非零值的起始位置
    l2计算序列f非零值的宽带
    t计算序列f非零值的时间向量
    subplot(221);plot(t1,f1) 
    subplot(222);plot(t2,f2)
    subplot(223

2、例子:

image
复制代码
    clear all;
    计算连续时间信号卷积积分并绘波形
    t110.013;
    f12定义信号 
    t2t1;
    f20.52定义信号 
    [t,f]

转载于:https://www.cnblogs.com/BlueMountain-HaggenDazs/p/4470640.html

全部评论 (0)

还没有任何评论哟~