sawtooth function

Sawtooth or triangle wave

Sawtooth or triangle wave

Returns samples of the sawtooth function at the times indicated by t.

sawtooth(t, width = 1)

Arguments

  • t: Sample times of unit sawtooth wave specified by a vector.
  • width: Real number between 0 and 1 which specifies the point between 0 and 2π2 \pi where the maximum is. The function increases linearly from -1 to 1 in the interval from 0 to 2πwidth 2 * \pi * width, and decreases linearly from 1 to -1 in the interval from 2πwidth2 * \pi * width to c("2\n2\n", "pi* \\pi"). Default: 1 (standard sawtooth).

Returns

Sawtooth wave, returned as a vector.

Details

The code y <- sawtooth(t) generates a sawtooth wave with period 2π2\pi 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π2\pi and to increase linearly with time with a slope of 1/π1/\pi at all other times.

y <- sawtooth(t, width) generates a modified triangle wave with the maximum location at each period controlled by width. Set width

to 0.5 to generate a standard triangle wave.

Examples

T <- 10 * (1 / 50) fs <- 1000 t <- seq(0, T-1/fs, 1/fs) y <- sawtooth(2 * pi * 50 *t) plot(t, y, type="l", xlab = "", ylab = "", main = "50 Hz sawtooth wave") T <- 10 * (1 / 50) fs <- 1000 t <- seq(0, T-1/fs, 1/fs) y <- sawtooth(2 * pi * 50 * t, 1/2) plot(t, y, type="l", xlab = "", ylab = "", main = "50 Hz triangle wave")

Author(s)

Juan Aguado.

Conversion to R by Geert van Boxtel, G.J.M.vanBoxtel@gmail.com .

  • Maintainer: Geert van Boxtel
  • License: GPL-3
  • Last published: 2024-09-11