八度-锯齿波函数

Octave - sawtooth function

我想在 Octave 中绘制锯齿波函数。我知道我可以使用命令 "sawtooth(t)" 但我没有软件包,所以我创建了以下函数。

function x = pieceWise2bis(t)
x = zeros (size (t));

ind1 = t >= 10 & t < 13;
x(ind1) = +20;

ind2=t >= 13 & t < 16;
x(ind2) = -20;

ind3=t >= 16 & t < 19;
x(ind3) = +20;

ind4=t >= 19 & t < 22;
x(ind4) = -20;
endfunction

当我绘制这个函数时,我没有得到我正在寻找的结果,因为我想要一个真正的锯齿函数,而不是像那样的带有垛口的周期函数。 有人能告诉我如何调整我的代码吗? 谢谢

似乎通过安装需要控制的信号来加载锯齿波的常用方法....不起作用,无论如何你最好自己写这个。这是实现此目的的众多方法之一:

clear; %% this line tells octave the remainder is more than just a func.
## usage: ST = sawtooth (time)
function ST = sawtooth (time)
  ST=rem(time,2*pi)/2/pi;
endfunction

time=linspace(0,20,101); % second line of main program (clear is 1st)
PriSawtooth=sawtooth(time);
plot(time,PriSawtooth,'linewidth',1)