# GSAWTOOTH

## Purpose:

Generates a sawtooth wave.

## Syntax:

GSAWTOOTH(length, spacing,
frequency, phase, width, duty)

length |
- |
An integer, the length of the output series. |

spacing |
- |
A real, the spacing (delta x) between each
point on the x-axis. |

frequency |
- |
Optional. A real, the
frequency specified in cycles per second (Hertz). Defaults to 1. |

phase |
- |
Optional. A real, the
phase specified in radians. Defaults to 0. |

width |
- |
Optional. A real
between 0 and 1. The fraction of the
sawtooth period where the maximum value occurs. Defaults to 1.0. |

duty |
- |
Optional. A real, between
0 and 100. The duty cycle, the percentage of a period the sawtooth is
"on". Defaults to 100.0. |

## Returns:

A series.

## Example:

gsawtooth(1000, 1/1000, 3)

Generates 1000 points of a 3 Hz sawtooth with a sample rate of 1000
Hz. The peak value occurs at the end of each period.

## Example:

W1: gsawtooth(1000, 1/1000, 4)

W2: gtriwave(1000, 1/1000, 4);overp(w1, lred)

W1 contains 1000 points of an 4 Hz sawtooth with a sample rate of 1000
Hz. W2 contains 1000 points of an 4 Hz triangle
wave with a sample rate of 1000 Hz. The overplot provides
a graphical comparison.

## Example:

W1: gsawtooth(1000, 1/1000, 1, 0, 0.8)

W2: gsawtooth(1000, 1/1000, 1, 0, 0.5)

W3: gsawtooth(1000, 1/1000, 1, 0, 0.2)

W4: gsawtooth(1000, 1/1000, 1);overp(w1, w2, w3)

legend(W4, 0.05, 1.1, "Width:1.0", "Width:0.8",
"Width:0.5", "Width:0.2")

W1 through W4 contain 1000 points of an 1 Hz sawtooth with a sample
rate of 1000 Hz. The **width** parameter
for each sawtooth is set to 0.8, 0.5, 0.2 and 1.0 respectively. The overplot
in W4 provides a graphical comparison of the effect of the differing sawtooth
widths.

## Remarks:

The sawtooth is normalized with an amplitude between 0.0 and 1.0. The
leading edge of the sawtooth rises monotonically.

See GTRIWAVE to generate a triangle wave.

## See Also:

GSQRWAVE

GTRIWAVE