专栏
标签
Syslab中生成自定义的非周期三角波的函数
技术分享
发布于 2025-07-22 13:36:14
查看 1过去315天

针对上述问题,可以采用 tripuls 函数:

1.运行下面代码,生成 200 ms 的对称三角脉冲,采样率为 10 kHz,宽度为 40 ms:

using TyPlot 
using TySignalProcessing
fs = 10e3
t = [-0.1:1/fs:0.1;]
w = 40e-3
y = tripuls(t,w)

image.png
2.绘制三角波图像:

plot(t,y)

image.png
3.改变输入的第一个参数,使三角波向左位移 45 毫秒,改变第二个参数,使三角波宽度变为一半,输入第三个参数,使三角波向左倾斜四十五度:

tpast = -45e-3
spast = -0.45
xpast = tripuls(t.-tpast,w/2,spast)

image.png
4.绘制第一个三角波和第二个自定义的三角波:

figure()
plot(t,y,t,xpast)

5.可以看到自定义的三角波实现了所需的效果:
image.png
6.tripuls 函数的用法:

函数库: TySignalProcessing

语法:

y = tripuls(t)
y = tripuls(t, w, s)

说明: y = tripuls(t) 在数组 t 中指示的采样时间返回一个连续的、非周期性的、对称的、单位高度的三角脉冲,以 t = 0 为中心;y = tripuls(t, w, s) 生成一个宽度为 w 且倾斜为 s 的三角形。

示例:

using TyPlot 
using TySignalProcessing
fs = 10e3
t = [-0.1:1/fs:0.1;]
w = 40e-3
y = tripuls(t,w)
tpast = -45e-3
spast = -0.45
xpast = tripuls(t.-tpast,w,spast)
tfutr = 60e-3
sfutr = 1
xfutr = tripuls(t.-tfutr,w/2,sfutr)
plot(t,y,t,xpast,t,xfutr)
ylim([-0.2 1.2])

image.png
更多有关 tripuls 函数的相关信息可以参阅帮助文档:
image.png

所属专栏:Syslab基础平台
产品信息:Syslab科学计算环境
科学计算

全部回答

暂无数据
暂无数据
用户
和原帖交流更多问题细节吧,去
我要发帖 我要发帖
资料中心 资料中心
查看更多>
热门帖子 热门帖子
主要贡献者 主要贡献者
过去7天