The mathematical expression of the gate function is:
example1: The matlab code for the rectangular pulse signal is as follows:
%矩形脉冲信号
clc;
clear;
close all;
t=0:0.001:4;
T=1;
ft=rectpuls(t-2*T,2*T);
plot(t,ft);
The result of the operation is as follows:
example2: The matlab code for the rectangular pulse signal is as follows:
t=-4:0.001:4; %定义时间变量范围
T=2; %定义矩形波的脉宽
f=rectpuls(t,T); %生成一个矩形波信号
plot(t,f) %绘制矩形波图形
grid on; %显示网格线
axis([-4 4 -0.5 1.5]) %限制图的横纵坐标的显示范围
xlabel('t'); %给横坐标命名
ylabel('f(t)'); %给纵坐标命名
title('矩形波信号f(t)'); %给整个图形定义一个标题
The result of the operation is as follows:
References: Signals and Systems (2nd Edition) - edited by Chen Houjin