Admin Production ni-theme
Current Publication

SineWave

LabWindows/CVI

SineWave

Advanced Analysis Library Only

AnalysisLibErrType SineWave (ssize_t numberOfElements, double amplitude, double frequency, double *phase, double sineWave[]);

Purpose

Generates an array that contains a sine wave. SineWave generates the ith element of the output array x according to the following formula:

xi = amplitude × sin(phi)

where

where the normalized frequency is the ratio of the actual frequency to the sampling frequency.

For example, if the actual frequency desired is 100 Hz and the sampling frequency is 500 Hz, the normalized frequency is 0.2. You can use SineWave to simulate a continuous acquisition from a sine wave function generator. The unit of the input phase is in degrees, and SineWave sets phase to (phase + f × 360.0 × n) mod 360.0 before it returns.

Parameters

Input
Name Type Description
numberOfElements ssize_t Number of samples, or data points, to generate in the sine wave signal.
amplitude double Amplitude of the resulting sine wave signal.

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

Default Value: 7.8125E-3 (1 cycle/128 samples).
Output
Name Type Description
phase double Pointer to the initial phase, in degrees, of the sine wave signal SineWave generates.

Upon completion of SineWave, phase points to the phase of the next portion of the signal. Use this parameter in the next call to SineWave to simulate a continuous acquisition.

You must pre-initialize this value to a valid value.
sineWave double [] The generated sine 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.

Additional Information

Library: Advanced Analysis Library

Include file: analysis.h

LabWindows/CVI compatibility: LabWindows/CVI 3.1 and later

Examples

Refer to the following examples that use the SineWave function:

  • analysis\cxwindowing.cws

    Open example
  • analysis\peakest.cws

    Open example
  • analysis\polyfit1.cws

    Open example
  • analysis\thd.cws

    Open example
  • analysis\windowng.cws

    Open example