Admin Production ni-theme
Current Publication

SpectrumUnitConversion

LabWindows/CVI

SpectrumUnitConversion

Advanced Analysis Library Only

AnalysisLibErrType SpectrumUnitConversion (double spectrum[], ssize_t numberOfElements, int type, int scalingMode, int displayUnits, double df, WindowConst 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 [] 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 ssize_t Number of elements in the input spectrum.
type int Type of the input spectrum.

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 int 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 int 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 The frequency interval, in Hertz, as output by AmpPhaseSpectrum, AutoPowerSpectrum, CrossPowerSpectrum, NetworkFunctions, or TransferFunction.

Default Value: 1.0.
windowConstants WindowConst 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 [] 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 char 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.

Additional Information

Library: Advanced Analysis Library

Include file: analysis.h

LabWindows/CVI compatibility: LabWindows/CVI 3.1 and later

Example

Refer to analysis\peakest.cws for an example of using the SpectrumUnitConversion function.