This is a pre-release version (latest).Go to latest (1.18.0)
{ } Raw JSON

bundles / scipy latest / scipy / signal / _waveforms / sawtooth

function

scipy.signal._waveforms:sawtooth

source: build-install/usr/lib/python3.14/site-packages/scipy/signal/_waveforms.py:19

Signature

def sawtooth(t, width = 1.0)

Summary

Return a periodic sawtooth or triangle waveform.

Extended Summary

The sawtooth waveform has a period 2*pi, rises from -1 to 1 on the interval 0 to width*2*pi, then drops from 1 to -1 on the interval width*2*pi to 2*pi. width must be in the interval [0, 1].

Note that this is not band-limited. It produces an infinite number of harmonics, which are aliased back and forth across the frequency spectrum.

Parameters

t : array_like

Time.

width : array_like, optional

Width of the rising ramp as a proportion of the total cycle. Default is 1, producing a rising ramp, while 0 produces a falling ramp. width=0.5 produces a triangle wave. If an array, causes wave shape to change over time, and must be the same length as t.

Returns

y : ndarray

Output array containing the sawtooth waveform.

Examples

A 5 Hz waveform sampled at 500 Hz for 1 second:
import numpy as np
from scipy import signal
import matplotlib.pyplot as plt
t = np.linspace(0, 1, 500)
✓
plt.plot(t, signal.sawtooth(2 * np.pi * 5 * t))
✗
[<matplotlib.lines.Line2D object at 0x7f3f600c9fd0>]

Aliases

  • scipy.signal.sawtooth

Referenced by