SpectrumUnitConversion

Advanced Analysis Library Only

AnalysisLibErrType SpectrumUnitConversion (double spectrum[], int numberOfElements, int type, int scalingMode, int displayUnits, double df, WindowStruct windowConstants, double convertedSpectrum[], char unitString[]);

Purpose

Converts the input spectrum, which is the power, amplitude, or gain, to alternate formats such as log, decibels or dBm, and spectral density.

Parameters

Input
Name Type Description
spectrum double-precision array Input array that contains a spectrum of the type specified by the spectrum selector.

This value must be a power, amplitude, or gain spectrum.
numberOfElements integer Number of elements in the input spectrum.
type integer Type of the input spectrum.

type has the values shown in the following table.

Value Description
0 (Default) Power (volts rms square); AutoPowerSpectrum calculates
1 Amplitude (volts, root-mean-square); AmpPhaseSpectrum calculates
2 Gain (amplitude ratio); TransferFunction calculates
scalingMode integer Type of the scaling of the output spectrum.

scalingMode has three selections for the output unit type, as shown in the following table.

Value Description
0 (Default) Linear
1 Decibels
2 dBm
displayUnits integer Unit of the output spectrum, assuming "V" for unitString.

Value Description
0 (Default) Vrms (volts rms)
1 Vpk (volts peak)
2 Vrms2 (volts squared rms)
3 Vpk2 (volts squared peak)
4 Vrms/ (volts rms per root Hertz)
5 Vpk/ (volts peak per root Hertz)
6 Vrms2/ (volts squared rms per Hertz)
7 Vpk2/ (volts squared peak per Hertz)

The last four selections are amplitude spectral density (4, 5) and power spectral density (6, 7).
df double-precision The frequency interval, in Hertz, as output by AmpPhaseSpectrum, AutoPowerSpectrum, CrossPowerSpectrum, NetworkFunctions, or TransferFunction.

Default Value: 1.0.
windowConstants WindowStruct Structure that contains the following useful constants for the selected window:

enbw is the equivalent noise bandwidth of the selected window. You can use this value to calculate the power in a given frequency span.

coherentgain is the peak gain of the window, relative to the peak gain of the Rectangular window. SpectrumUnitConversion uses this value normalize peak signal gains to that of the Rectangular window.

ScaledWindowEx outputs this structure.
Output
Name Type Description
convertedSpectrum double-precision Input spectrum, power, amplitude, or gain, to convert to alternate formats such as log, decibels or dBm, and spectral density. The size of this array must be at least numberOfElements.
unitString string On input, the string that contains the base unit of the analyzed signal; V for a voltage signal.

Upon completion of SpectrumUnitConversion, the unit of the output convertedSpectrum. The size of this string must be at least (12 + size of unitString).

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.