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

您所在的位置:网站首页 方波信号怎么用matlab画 Matlab与信号处理(三):常用连续时间信号

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

2024-03-21 10:44| 来源: 网络整理| 查看: 265

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)');

 

 

 



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3