Generates a triangular wave in accordance with the specified parameters.
GTRIWAVE(length, spacing, frequency, phase, duty)
length |
- |
An integer, the length of the output series. |
spacing |
- |
A real, the spacing (delta x) between each point on the |
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. |
duty |
- |
Optional. A real, between 0 and 100. The duty cycle, the percentage of a period the triangle wave is "on". Defaults to 100.0. |
A series.
gtriwave(100, 0.1, 2, 5)
creates a triangular wave of 100 points spaced 0.1 x-units apart. The series is also be shifted by five x-units (the offset value) on the x-axis. The values of this will vary between 1.0 and zero.
gtriwave(1000, 1/1000, 20)
generates 1000 samples of a 20 Hz triangular wave sampled at 1000 samples/sec.
gtriwave(1000, 1/1000, 20, 0, 60)
same as above except the duty cycle is 60%.
The triangular wave is generated by calculating:
and returns a rising ramp from 0 to 1 where s[n] is positive, and a falling ramp from 1 to 0 where s[n] is negative.
See GSAWTOOTH to generate a sawtooth wave.