GSQRWAVE

Purpose:

Generates a square wave in accordance with the specified parameters.

Syntax:

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 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.

duty

-

Optional. A real, between 0 and 100. The duty cycle, the percentage of a period the squarewave is "on". Defaults to 50.0.

Returns:

A series.

Example:

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.

Example:

gsqrwave(1000, 1/1000, 20)

 

generates 1000 samples of a 20 Hz square wave sampled at 1000 samples/sec.

Example:

gsqrwave(1000, 1/1000, 20, 0, 15)

 

same as above except the duty cycle is 15%.

Remarks:

The square wave is generated by calculating:

 

image\gsqr01.gif

 

and returns a step function with a value of 1 when s[n] is negative, and 0 when s[n] is positive.

 

See GRTSQR to generate a square wave with a specified rise time.

See Also:

GRTSQR

GSAWTOOTH

GSIN

GSTEPS

GTRIWAVE