MATLAB 连续时间信号处理

阶跃函数

用maple内置函数heaviside

syms t;
f = heaviside(t);
ezplot(f,[-3*pi,3*pi]);

用符号函数

syms t;
f = 1/2 + 1/2 * sign(t);

利用阶跃函数得到各种矩形波

f = heaviside(t+3)-2*heaviside(t);

常见信号的表示

% 指数信号的表示y=A*exp(a*t)
A = 1;
a = -0.4;
t = 0:0.01:10;
ft = A * exp(a*t);
plot(t, ft);
%正弦信号y=A*sin(w0*t+phi)
A = 1;
w0 = 2*pi;
phi = pi/6;
t = 0:0.001:8;
ft = A * sin(w0*t + phi);
plot(t,ft);
%抽样函数sinc(t)=sin(pi*t)/pi*t
t = -3*pi : pi/100 : 3*pi;
ft = sinc(t/pi);
plot(t, ft);
%矩形脉冲信号y=rectpuls(t,width)产生一个幅值为1,宽度为width,相对于t=0点左右对称的矩形波信号
t = 0 : 0.001 : 4;
T = 1;
ft = rectpuls(t-2*T, 2*T);
plot(t,ft);
%三角波脉冲信号y=tripuls(t,width,skew)用以产生一个最大幅度为1,宽度为width,斜度为skew的三角波信号。
%该函数的横坐标范围由向量t决定,是以t=0为中心向左右各展开width/2的范围。
%斜度skew是介于-11之间的值,它表示最大幅度1出现所对应的横坐标位置。
%一般地,最大幅度1出现在t=(width/2)×skew的横坐标位置
t = -3 : 0.001 : 3;
ft = tripuls(t,4,0.5);
plot(t,ft);
%周期性三角波信号y=sawtooth(t,width)用以产生一个周期为2*pi,最大幅度为1,最小幅度为-1的周期性三角波信号(又称锯齿波信号)。
%width表示最大幅度出现的位置
t = -5*pi : pi/10 : 5*pi;
ft = sawtooth(t,0.5);
plot(t,ft);
%一般周期性脉冲信号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这个额外参数等

%周期性矩形信号
t = -0.5 : 0.001 : 1.5;
d = 0:1/3:1;
y = pulstran(t,d,'rectpuls',0.1);
figure(1);
plot(t,y);
axis([-0.1 1.1 -0.1 1.1]);  %放后面

%周期三角波信号
t = -0.2:0.001:1.2;
d = 0:1/2:1;
y = pulstran(t,d,'tripuls',0.1,-1);
figure(2);
plot(t,y);
axis([-0.1 1.1 -0.1 1.1]);
t = 0 : 0.01 : 3;
z = 2 + exp(j*pi/4*t) + exp(j*pi/2*t);
subplot(2,2,1),plot(t,real(z)),title('实部')
subplot(2,2,3),plot(t,imag(z)),title('虚部')
subplot(2,2,2),plot(t,abs(z)),title('模')
subplot(2,2,4),plot(t,angle(z)),title('相角')

连续信号的时域运算

syms t
%f=sym('(t/2+1)*(heaviside(t+2)-heaviside(t-2))')
f = (t/2+1)*(heaviside(t+2)-heaviside(t-2));

subplot(2,3,1),ezplot(f,[-3,3]),title('f(t)')

y1 = subs(f,t,t+2)  //左移
subplot(2,3,2),ezplot(y1,[-5,1]),title('f(t+2)')

y2 = subs(f,t,t-2)  //右移
subplot(2,3,3),ezplot(y2,[-1,5]),title('f(t-2)')

y3 = subs(f,t,-t)   //反折
subplot(2,3,4),ezplot(y3,[-3,3]),title('f(-t)')

y4 = subs(f,t,2*t)  //尺度变换
subplot(2,3,5),ezplot(y4,[-2,2]),title('f(2*t)')

y5 = -f  //倒相
subplot(2,3,6),ezplot(y5,[-3,3]),title('-f(t)')

猜你喜欢

转载自blog.csdn.net/Shao_yihao/article/details/121406582