Matlab与信号处理(三):常用连续时间信号

1.门信号:

y=rectpuls(t):用于产生宽度为1的门信号。

y=rectpuls(t,w):用于产生指定宽度为w的门信号。 

%门信号
clc;clear;close all;
t=-3:0.001:3;
y=rectpuls(t);         %产生振幅为1,宽度为1的门信号
subplot(221);
plot(t,y);
axis([-2 2 -1 2]);grid on;
xlabel('t');ylabel('w(t)');
y=2.3*rectpuls(t,2);   %产生振幅为2.3,宽度为2的门信号
subplot(222);
plot(t,y);
axis([-2 2 -1 3]);grid on;
xlabel('t');ylabel('w(t)');
y=2*rectpuls(t-2,0.5); %产生振幅为2,宽度为0.5,对称轴为t=2的门信号
subplot(212);
plot(t,y)
axis([0 3 -1 3]);grid on;
xlabel('t');ylabel('w(t)');

 

2.周期方波信号:

x=square(2*pi*f*t,c):产生频率为f,占空比为c%的周期方波。

%周期方波
clc;clear;close all;
f=5;
nt=3;
N=15;
T=1/f;
dt=T/N;
n=0:nt*N-1;            
tn=n*dt;
%产生周期方波信号,频率为5,且振幅在0-2之间,占空比为25%
x=square(2*f*pi*tn,25)+1;
stairs(tn,x,'k');grid on;
axis([0 nt*T 1.1*min(x) 1.1*max(x)]);
xlabel('t');ylabel('x(t)');

 

3.单位阶跃信号:

y=heaviside(t-t0)

%单位阶跃信号
clc;clear;close all;
t=-1:0.01:2;
f=heaviside(t);
plot(t,f);
axis([-1 2 -0.5 1.5]);
title('u(t)');
xlabel('t');ylabel('f');

4.周期三角波信号: 

y=sawtooth(2*pi*f*t):产生频率为f,振幅从-1到1的锯齿波,其中的斜率为f。

y=sawtooth(2*pi*f*y,r):产生频率为f,振幅从-1到1的锯齿波,其中斜率为r*f。

%周期三角波信号
clc;clear;close all;
t=0:0.01:5;
f1=2;
f2=3;
y1=sawtooth(2*pi*f1*t,0.5);
y2=sawtooth(2*pi*f2*t);
subplot(211);
plot(t,y1);grid on;
xlabel('t');ylabel('y1');
subplot(212);
plot(t,y2);grid on;
xlabel('t');ylabel('y2');

5.非周期三角波信号:

y=tripuls(t,w,s):产生底为w,斜率为s的非周期三角波信号。

%非周期三角波信号
clc;clear;close all;
t=-2:0.001:2;
y=tripuls(t,4,0.5);
plot(t,y);grid on;
axis([-3 3 -1 2]);
grid on;
xlabel('t');ylabel('y(t)');

6.sinc信号: 

 y=sinc(t)

%sinc信号
clc;clear;close all;
t=-10:0.01:10;
y=sinc(t);
plot(t,y);

7. 随机信号:

Y=rand(n):返回一个n*n的随机矩阵。

Y=rand(m,n)或Y=rand([m n]):返回一个m*n的随机矩阵。

Y=rand(size(A)):返回一个和A有相同尺寸的随机矩阵。

%随机波形
clc;clear;close all;
tn=0:50;
N=length(tn);
x=rand(1,N);
plot(tn,x,'k');
ylabel('x(t)');

 

 

 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值