专栏
标签
Syslab中如何生成锯齿波或周期性三角波
技术分享
发布于 2025-07-22 13:36:11
查看 1过去315天

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

1.设置周期为 10,基本频率为 50 Hz,采样率为 1kHz:

using TySignalProcessing
using TyPlot
T = 10*(1/50)
fs = 1000
t = 0:1/fs:T-1/fs

2.生成锯齿波并绘制图像:

y = sawtooth(2*pi*50*t)
plot(t,y)
grid()

3.可以看到绘制出了需要的锯齿波:
image.png

4.更改输入的属性,生成标准的周期三角波并绘制图像:

x = sawtooth(2*pi*50*t,0.5)
figure()
plot(t,x)
grid()

5.可以看到生成了需要的周期三角波:
image.png

6.sawtooth 函数的用法

**函数库: **TySignalProcessing

语法:

y = sawtooth(t)
y = sawtooth(t,tmax)

说明: y = sawtooth(t) 为时间数组 t 的元素生成周期为 2π 的锯齿波

y = sawtooth(t,tmax) 生成修改后的三角波,每个周期的最大位置由 xmax 控制。 将 xmax 设置为 0.5 以生成标准三角波。

示例:

using TySignalProcessing
using TyPlot
T = 10*(1/50)
fs = 1000
t = 0:1/fs:T-1/fs
y = sawtooth(2*pi*50*t)
plot(t,y)
grid()

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

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

全部回答

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