# AmpPhaseSpectrum

Advanced Analysis Library Only

AnalysisLibErrType AmpPhaseSpectrum (double inputArray[], int numberOfElements, int unwrap, double dt, double amplitudeSpectrum[], double phaseSpectrum[], double *df);

## Purpose

Calculates the single-sided, scaled amplitude and phase spectra of a time-domain signal, X. AmpPhaseSpectrum calculates the amplitude spectrum as

and converts it to single-sided form. AmpPhaseSpectrum calculates the phase spectrum as

phase(FFT(X))

and converts it to single-sided form.

## Parameters

Input
Name | Type | Description
inputArray | double-precision array | The time-domain signal.
numberOfElements | integer | Number of elements in the input array. Default Value: 1024.
unwrap | integer | Controls the unwrapping of the phase spectrum. Valid values: 1 = enable phase unwrapping (Default) 0 = disable phase unwrapping (–Π phase +Π)
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
amplitudeSpectrum | double-precision array | Single-sided amplitude spectrum magnitude in volts, root-mean-square, if the input signal is in volts. If the input signal is not in volts, the results are in input signal units, root-mean-square. This array must be at least numberOfElements/2 elements long.
phaseSpectrum | double-precision array | Single-sided phase spectrum in radians. 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.