Generates a square wave in accordance with the specified parameters.
GSQRWAVE(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 squarewave is "on". Defaults to 50.0. |
A series.
gsqrwave(100, 0.1, 2, 5)
creates a square 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 series will be either at 1.0 or at zero.
gsqrwave(1000, 1/1000, 20)
generates 1000 samples of a 20 Hz square wave sampled at 1000 samples/sec.
gsqrwave(1000, 1/1000, 20, 0, 15)
same as above except the duty cycle is 15%.
The square wave is generated by calculating:
and returns a step function with a value of 1 when
See GRTSQR to generate a square wave with a specified rise time.