【 MATLAB 】信号处理工具箱的信号产生函数之 sawtooth 函数简记

网友投稿 1107 2022-05-30

sawtooth 函数

x = sawtooth(t) generates a sawtooth wave with period 2π for the elements of the time array t. sawtooth is similar to the sine function but creates a sawtooth wave with peaks of –1 and 1. The sawtooth wave is defined to be –1 at multiples of 2π and to increase linearly with time with a slope of 1/π at all other times.

x = sawtooth(t,xmax) generates a modified triangle wave with the maximum location at each period controlled by xmax.

上面两种形式是MATLAB官方的帮助文档给出的,但这并不是我今天想呈现给大家的,我想通过基本的解释,之后通过案例的对比来感受这个函数。更多的是体会参数xmax的含义。

x = sawtooth(t,xmax) ,t是时间阵列,也就是时间轴;xmax这个参数的含义是这个锯齿波的峰值位置位于哪里,没有这个参数的话,其实默认为1,此时,峰值位于最右侧;如果设置为0,则峰值在左侧;可想而知,如果为0.5,则峰值位于中间。

x = sawtooth(t) 生成一个周期为2π的锯齿波,类似于正弦波,只不过波形不一样而已。

如果想了解更多,在MATLAB的命令框里输入doc sawtooth,回车即可。

下面给出对比案例:

产生一个10个周期的锯齿波,其基波周期为50Hz,采样率为1kHz。

%Generate 10 periods of a sawtooth wave with a fundamental frequency of 50 Hz. The sample rate is 1 kHz.

clear

clc

close all

T = 10*(1/50);

Fs = 1000;

dt = 1/Fs;

t = 0:dt:T-dt;

x = sawtooth(2*pi*50*t);

plot(t,x)

title('50 Hz sawtooth waveform');

xlabel('t\s');

ylabel('amplitude');

grid on

将 sawtooth 函数改为:

x = sawtooth(2*pi*50*t, 0.5);

继续运行得到如下波形:(可见得到一个三角波)

将 sawtooth 函数改为:

【 MATLAB 】信号处理工具箱的信号产生函数之 sawtooth 函数简记

x = sawtooth(2*pi*50*t, 0);

继续运行得到如下波形:

MATLAB

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:OBS权限控制的几件事(一)
下一篇:【云小课】【第29课】不容错过!华为云新一代缓存“大咖”——云数据库 GaussDB(for Redis)
相关文章