# CrossPowerSpectrum

Advanced Analysis Library Only

AnalysisLibErrType CrossPowerSpectrum (double XArray[], double YArray[], int numberOfElements, double dt, double magSxy[], double phaseSxy[], double *df);

## Purpose

Calculates the single-sided, scaled cross power spectrum of two time-domain signals. The following formula defines the cross power spectrum:

where FFT*[X] is the complex conjugate of FFT[X] and n is the number of points in the arrays.

This function converts the cross power spectrum to single-sided magnitude and phase spectra.

## Parameters

Input
Name | Type | Description
XArray | double-precision array | Time-domain signal X.
YArray | double-precision array | Time-domain signal Y.
numberOfElements | integer | Number of elements in the input array. Default Value: 1024.
dt | double-precision | Sampling period of the time-domain signal, usually in seconds. dt = 1/fs, where fs is the sampling frequency of the time-domain signal. Default Value: 1.0.
Output
Name | Type | Description
magSxy | double-precision array | Single-sided magnitude cross power spectrum between signals XArray and YArray in volts rms square if the input signals are in volts. If the input signals are not in volts, the results are in input signal units rms square. This array must be at least numberOfElements/2 elements long.
phaseSxy | double-precision array | Single-sided phase cross spectrum in radians, showing the difference between the phases of signal YArray and signal XArray. This array must be at least numberOfElements/2 elements long.
df | double-precision | Points to the frequency interval, in Hertz, if dt is in seconds. df = 1/(numberOfElements × dt)

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