Sawtooth or triangle wave
x = sawtooth(t)
x = sawtooth(t,xmax)
generates a sawtooth wave with period 2π for the elements of the
x = sawtooth(
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.
Generate 10 periods of a sawtooth wave with a fundamental frequency of 50 Hz. The sample rate is 1 kHz.
T = 10*(1/50); Fs = 1000; dt = 1/Fs; t = 0:dt:T-dt; x = sawtooth(2*pi*50*t); plot(t,x) grid on
Plot the power spectrum.
t— Time array
Time array, specified as a vector, matrix, or N-D array.
sawtooth operates along the first array dimension
t with size greater than 1.
xmax— Wave maximum location
Wave maximum location, specified as a scalar between 0 and 1.
xmax determines the point between 0 and
2π at which the wave reaches its maximum. The
function increases from –1 to 1 on the interval 0 to 2π ×
xmax, then decreases linearly from 1 to –1 on the
interval 2π ×
2π. The shape then repeats with a period of
xmax = 0.5 specifies a standard triangle wave,
symmetric about time π with a peak-to-peak amplitude of 1.
x— Sawtooth wave
Sawtooth wave, returned as a vector, matrix, or N-D array.