信号的产生——三角波函数sawtooth
函数sawtooth可以产生锯齿波或三角波信号。
格式一:x=sawtooth(t)
功能:产生周期为2pi,振幅为-1~1的锯齿波。
在2pi的整数倍处值为-1~1,这一段波形斜率为1/pi。
格式二:sawtooth(t,width)
功能:产生三角波,width在0到1之间。
E_2_9_sawtooth.m
产生周期为0.02的三角波。
% E_2_9_sawtooth.m
% 产生周期为0.02的三角波。
clc
clear
close all
Fs = 10000; t=0:1/Fs:1;
x1 = sawtooth(2*pi*50*t,0);
x2 = sawtooth(2*pi*50*t,1);
subplot(211); plot(t,x1); axis([0,0.2,-1,1]);
grid on; xlabel('t'); ylabel('x1(t)');
subplot(212); plot(t,x2); axis([0,0.2,-1,1]);
grid on; xlabel('t'); ylabel('x2(t)');