SquareWave

Advanced Analysis Library Only

AnalysisLibErrType SquareWave (int numberOfElements, double amplitude, double frequency, double *phase, double dutyCycle, double squareWave[]);

Purpose

Generates an array that contains a square wave. SquareWave generates the output array x according to the following formula:

xi = amplitude × square (phase + f × 360 × i)

where f is normalized frequency and where

You can use SquareWave to simulate a continuous acquisition from a square wave function generator. The unit of the input phase is in degrees, and SquareWave sets phase to (phase + f x 360.0 x n) modulo 360.0 before it returns.

Parameters

Input
Name Type Description
numberOfElements integer Number of elements to generate in the square wave signal.
amplitude double-precision Amplitude of the resulting square wave signal.

Default Value: 1.0.
frequency double-precision Frequency of the resulting square wave signal in normalized units of cycles/sample.

Default Value: 7.8125E-3 (1 cycle/128 samples).
dutyCycle double-precision Contains the duty cycle, in percent, of the generated square wave signal.

Default Value: 50.0.
Output
Name Type Description
phase double-precision Points to the initial phase, in degrees, of the generated square wave signal.
phase double-precision Upon completion of SquareWave, phase points to the phase of the next portion of the signal. Use this parameter in the next call to SquareWave to simulate a continuous acquisition.
squareWave double-precision array The generated square wave signal.

Return Value

Name Type Description
status AnalysisLibErrType A value that specifies the type of error that occurred. Refer to analysis.h for definitions of these constants.