matlab生成锯齿波、倒锯齿波和三角波的函数都是 sawtooth
生成锯齿波
使用的函数
f=sawtooth(2*pi*f*t); 其中 f 为频率
锯齿波的频率控制和正弦波和三角波函数的控制是一样的(见matlab 生成正弦波)
假设锯齿波的频率为2Hz
t=0:0.001:1;
f=sawtooth(2*pi* 2 *t + (pi/2));
plot(t,f,'r','LineWidth',3);
grid on;
axis([-0.5,1.5, -1.5,1.5]);
生成倒锯齿波
使用的函数
f=sawtooth(2*pi*f*t, 0); 其中 f 为频率,0是指明画的是倒三角波
假设频率为2
t=0:0.001:1;
f=sawtooth(2*pi* 2 *t, 0);
plot(t,f,'r','LineWidth',3);
grid on;
axis([-0.5,1.5, -1.5,1.5]);
生成三角波
使用的函数
f=sawtooth(2*pi*f*t, 1/2); 其中 f 为频率,1/2是指明画三角波
假设频率为2
t=0:0.001:1;
f=sawtooth(2*pi* 2 *t + (pi/2), 1/2);
plot(t,f,'r','LineWidth',3);
grid on;
axis([-0.5,1.5, -1.5,1.5]);