An object EngeeDSP.spectrumAnalyzer displays the frequency spectrum of the signals in the time domain.
The spectrum analyzer represents the frequency spectrum in the form of a spectrum or a spectrogram.
The object performs the spectrum calculation using the filter bank method and the method of averaged modified Welch periodograms. For more information, see Algorithms.
The spectrum analyzer can display the signal power spectrum in three units: W, dBm and dBW. For more information about power conversion between these three units, see Transfer of power from one unit of measurement to another.
To create a spectrum analyzer object, follow these steps:
Create an object EngeeDSP.spectrumAnalyzer and set its properties.
Call the object with arguments as if it were a function.
scope = EngeeDSP.spectrumAnalyzer(name = value) — creates a system object EngeeDSP.spectrumAnalyzer with the specified property Name, set to the specified value Value.
You can specify additional arguments as a name-value pair in any order (Name1=Value1,…,NameN=ValueN).
Using
scope(signal) — displays the frequency spectrum of the input signal signal in the time domain in the spectrum analyzer.
scope(signal)
scope(signal1,signal2,…,signalN) — displays the frequency spectrum of multiple input signals signal1,signal2,…,signalN in the time domain in the spectrum analyzer. Each signal is interpreted as a separate channel.
scope(signal1,signal2,signal3)
Arguments
Input arguments
signal — input signal
+
scalar | vector | the matrix
Details
An input signal or visualization signals specified as a scalar, vector, or matrix.
The number of channels in each signal can be different, but the frame size of each signal must be the same.
Axis limits they are set as a tuple of real numbers. Default value (-80, 20).
#CenterFrequency —
the central frequency for calculating the spectrum
Real number
Details
The center of the frequency range in which the spectrum is calculated and plotted is set as a real scalar in Hz. The total frequency range determined by Span and by this property, it must be within Nyquist frequency range.
Dependencies
To use this property, specify FrequencySpan = "span-and-center-frequency".
#TimeSpanSource —
the source of the time interval of the spectrogram
String
Details
The source of the time interval of the spectrogram. Possible values:
"auto" — the spectrogram displays 100 lines of the spectrogram at any given time.
"property" — the spectrogram uses the duration in seconds specified in the property TimeSpan.
The specified time interval must be at least twice as long as the duration of the number of samples required to update the spectrum.
#FrequencyScale —
scale for frequency display
String
Details
Scale to display the frequency. Possible values:
"linear" (default) — use a linear scale to display frequencies along the axis ;
"log" — use a logarithmic scale to display frequencies along the axis .
You cannot assign a value to this property. "log" If the value is PlotAsTwoSidedSpectrum = true.
#FrequencyResolutionMethod —
the method of frequency resolution of the spectrum analyzer
String
Details
The method of frequency resolution of the spectrum analyzer. Possible values:
"rbw" (by default) — properties RBWSource and RBW the frequency resolution (in Hz) of the analyzer is controlled;
"num-frequency-bands" — properties FFTLengthSource and FFTLength they control the frequency resolution. This value can only be set if Method = "filter-bank";
"window-length" — property WindowLength controls the frequency resolution. This value can only be set if Method = "welch".
"spectrum" (default) — displays the frequency spectrum of the signals;
"spectrogram" — display of the signal spectrogram. The spectrogram shows the change in the frequency composition of the signal over time. Each line of the spectrogram represents one periodogram.;
"spectrum-and-spectrogram"— Simultaneous display of the spectrum and spectrogram.
"vertical" — allows you to position the spectrum above the spectrogram;
"horizontal" — allows you to place two views side by side.
Dependencies
To use this property, specify ViewType = "spectrum-and-spectrogram".
#PlotAsTwoSidedSpectrum —
building a two-way spectrum
Logical
Details
Constructing a two-way spectrum. Possible values:
true (by default) — calculate and plot a two-way spectrum. If the input signal is complex, you must set this property to true;
false — calculate and construct a one-sided spectrum. If this property matters false, the input signal must have a real value.
If this property matters false, the spectrum analyzer uses an overlap of spectra. Axis values twice the amplitude that would have been if this property had been important. true, except for 0 and Nyquist frequencies. The one-way spectral power density (SPM) contains the full signal power in the frequency range from DC to half the Nyquist frequency.
#OverlapPercent —
percentage of overlap between the previous and next data segment
Real number
Details
The percentage of overlap between the previous and current buffered data segments, specified as a scalar in the range [0,100). The overlap creates a window segment that the object uses to calculate the spectrum.
The time interval for displaying the spectrogram in seconds, set as a positive scalar. It is necessary to set a time interval at least twice as long as the duration of the number of samples required to update the spectrum.
Dependencies
To use this property, specify ViewType = "spectrogram" or ViewType = "spectrum-and-spectrogram" and TimeSpanSource = "property".
The resolution bandwidth (RBW) in Hz, set as a positive scalar. Specify a value to ensure that there are at least two RBW intervals in the specified frequency range. The ratio of the total range to RBW satisfies this condition.:
The value must be less than half of the frequency range specified by the parameter FrequencySpan.
RBW controls the spectral resolution of the displayed signal. The RBW value defines the interval between the frequencies that can be distinguished. A lower value provides higher spectral resolution and reduces noise levels. That is, the spectrum analyzer can distinguish between frequencies located closer to each other. However, this leads to an increase in the scan time.
#AveragingMethod —
the spectrum averaging method
String
Details
The method of spectrum averaging. Possible values:
"vbw" — the video band method. The object uses a low-pass filter to smooth the curve and reduce noise. Use the properties VBWSource and VBW to specify the value of the video band.
"exponential" — weighted average of the counts. The object calculates the average value based on samples weighted by an exponentially decreasing forgetting coefficient. Use the property ForgettingFactor to specify a weighted forgetting rate.
#ColorLimits —
color boundaries of the spectrogram
Details
The color boundaries of the spectrogram, defined as a tuple of real numbers. Default value (-80, 20).
Dependencies
To use this property, specify ViewType = "spectrogram" or ViewType = "spectrum-and-spectrogram".
#SpectrogramChannel —
the channel for which the spectrogram is being constructed
Int64 integer
Details
The channel for which the spectrogram is being constructed is specified as a positive integer in the range [1, N], where N — the number of input channels.
Dependencies
To use this property, specify ViewType = "spectrogram" or ViewType = "spectrum-and-spectrogram".
#FullScaleSource —
source of the dBFS scale factor
String
Details
The source of the dBFS scale factor. Possible values:
"auto" — the spectrum analyzer relies on the maximum value of the input data;
"property" — the property is being used FullScale.
"power-density" — spectral power density. The spectral power density is the square of the amplitude of the spectrum normalized to the bandwidth. 1 Hz;
"rms" — the RMS value. Use this option to view the frequency of voltage or current signals.
When a new value is assigned, the value changes SpectrumUnits:
by "power" on "dBm";
by "power-density" on "dBm/Hz";
by "rms" on "Vrms".
#StopFrequency —
the final frequency for calculating the spectrum
Real number
Details
The final frequency in the frequency range in which the spectrum analyzer calculates and plots the spectrum is given as a real scalar in Hz. The total range defined by this property and the property StartFrequency, must be within the range of Nyquist frequency range.
Dependencies
To use this property, specify FrequencySpan = "start-and-stop-frequencies".
#SampleRate —
Sampling rate of the input signal
Real number
Details
The sampling frequency of the input signal in Hz, set as a positive scalar.
#Span —
the frequency range in which the spectrum is calculated
Real number
Details
The frequency range in which the spectrum analyzer calculates and plots the spectrum is set as a positive scalar in Hz. The total frequency range determined by CenterFrequency and by this property, it must be within Nyquist frequency range.
Dependencies
To use this property, specify FrequencySpan = "span-and-center-frequency".
#TimeResolutionSource —
the time resolution source of each line of the spectrogram
String
Details
The time resolution source of each line of the spectrogram. Possible values:
"auto" (by default);
"property".
If for the parameters RBWSource and TimeResolutionSource the value is set "auto" Then RBW it is set in such a way that one frequency range contains 1024 the interval RBW. The time resolution is set to 1/RBW.
If for RBWSource the value is set "auto", and for TimeResolutionSource — value "property", then the time resolution becomes the main control element, and RBW is set to 1/TimeResolution Hz.
If for RBWSource the value is set "property", and for TimeResolutionSource — value "auto", then the main control element becomes RBW, and the time resolution is set to 1/RBW with.
If for RBWSource and TimeResolutionSource the value is set "property", then the specified time resolution value must be equal to or exceed the minimum achievable time resolution, determined by the ratio 1/RBW. Several spectrum calculations are combined into a single spectrogram line to obtain the required time resolution.
Dependencies
To use this property, specify ViewType = "spectrogram" or ViewType = "spectrum-and-spectrogram".
#ReferenceLoad —
reference load for calculating power levels
Real number
Details
The load that the spectrum analyzer uses as a reference for calculating power levels is indicated as a positive scalar in ohms.
The method of calculating the spectrum. Possible values:
"filter-bank" (by default) — using a filter bank to calculate the power spectrum. Compared to the Welch method, this method has a lower noise level, better frequency resolution, less spread of the spectrum, and requires fewer samples to update. For more information, see Spectrum Calculation — filter bank.
The length of the window in samples that the object uses to calculate the spectrum, set as an integer greater than 2. This property controls the frequency resolution.
#StartFrequency —
the initial frequency for calculating the spectrum
Real number
Details
The initial frequency in the frequency range in which the spectrum analyzer calculates and plots the spectrum is set as a real scalar in Hz. The total range defined by this property and StopFrequency, must be within Nyquist frequency range.
Dependencies
To use this property, specify FrequencySpan = "start-and-stop-frequencies".
#SidelobeAttenuation —
attenuation of the side lobes
Real number
Details
The attenuation of the side lobes of the window in decibels (dB) is indicated as a positive scalar value greater than or equal to 45.
Dependencies
To use this property, specify Window = "chebyshev" or Window = "kaiser".
#Window —
window function applied to accumulated data
String
Details
A window function applied to the accumulated data. Possible values:
"hann" (by default) — for more information, see hann;
Transfer of power from one unit of measurement to another
Details
The spectrum analyzer provides three units for measuring spectral power density: W/Hz, dBm/Hz and dBW/Hz.
The corresponding units of power measurement are W, dBm, and dBW.
In electrical applications, you can also view the RMS value of a signal in V (RMS value), DBMQ, or dBV. The default spectrum type is the power in dBm.
transfer power from Watts to dBW and dBm
The power in dBW is determined by the formula:
The power in dBm is determined by the formula:
For a sinusoidal signal with an amplitude of 1 The power of the one-way spectrum in Watts is determined by the formula:
The corresponding power in dBm is calculated using the formula:
For a white noise signal, the spectrum is flat for all frequencies.
Consider a white noise signal with variance 1e-4.
Thus, the power per unit of bandwidth () is equal to 1e-4.
For a one-way spectrum in the range the total white noise power in watts is determined by the formula:
where
— this is the sampling frequency of the input signal;
is the ratio of total bandwidth to bandwidth resolution ().
For a one-way spectrum, the total bandwidth is half the sampling frequency.
Consider the sampling rate 44100 Hz and bandwidth resolution 21.53 Hz.
At these values, the total white noise power in Watts is 0.1024 Tue.
The white noise power in dBm can be calculated using the formula:
transfer power from Watts to full-scale dB
If you set the spectral units to dBFS and the full scale (FullScaleSource) to the mode "auto", then the power in dBFS it will be calculated as follows:
where
— power in watts;
for double precision and floating point signals — this is the maximum value of the input signal;
for fixed-point or integer signals — this is the maximum value that can be represented.
If you set the full scale (FullScaleSource) to the mode "property", then the power in dBFS it will be calculated as follows:
For a sinusoidal signal with an amplitude of 1 The power of the one-sided spectrum in Watts is determined by the formula:
The corresponding power in dB of full scale is calculated using the formula:
transfer power from dBm to RMS value in
The power in dBm is determined by the formula:
The voltage (RMS value) is calculated using the formula:
In the previous example equal to 26.9897 dBm.
Meaning calculated as:
Algorithms
Spectrum Calculation — filter bank
Details
If for Method set the value "filter-bank" then the spectrum analyzer will use a filter bank to calculate the power spectrum.
The filter bank separates the broadband input signal with sampling rate for multiple narrowband signals with sampling rate .
Variable represents the number of frequency bands in the filter bank.
In the spectrum analyzer is equal to the number of data points required to achieve the specified resolution band value (RBW) or 1024, depending on which value is greater.
After the spectrum analyzer divides the broadband input signal into several narrow bands, it calculates the power in each narrow frequency band using the following equation:
where is each value it is a calculation of power in a narrow frequency band, and — the length of the narrowband signal for .
Power values in all narrow frequency bands (denoted by ) form a vector :
The spectrum analyzer averages the current vector with previous vectors using one of the sliding averaging methods: over the video band or exponential weighting.
The result of the averaging operation forms a vector for calculating the spectrum.
For more information about averaging methods, see The averaging method.
The spectrum analyzer uses the RBW value (Hz) or the number of frequency bands to determine the length of the input frame.
"auto" — the spectrum analyzer determines the appropriate resolution band to ensure the presence of 1024 bandwidth resolution intervals in a given frequency range.
In this case, the spectrum analyzer calculates RBW using the formula:
"property" — the spectrum analyzer calculates the number of samples using the formula:
where
— the sampling frequency of the input signal, set by the property SampleRate in Hz;
— specified in RBW The value of the resolution band must be such that there are at least two RBW intervals in the specified frequency range.
The ratio of the total range to RBW must be greater than two:
;
— the range in which the spectrum analyzer calculates and plots the spectrum.
If specified FrequencyResolutionMethod = "num-frequency-bands", then the resulting resolution bandwidth will be:
Spectrum calculation — the Welch method
Details
If for Method set the value "welch", then the calculation of the power spectrum is an averaged modified periodogram.
The algorithm of the spectrum analyzer consists of the following steps:
Buffers the input data into data segments consisting of points.
Each data segment is divided into overlapping data segments, each with a length of , overlapping on points.
The data segments can be represented as follows:
If , then the overlap is 50%.
If , then the overlap is 0%.
Applies a window to each of the overlapping data segments in the time domain.
If as a resolution method FrequencyResolutionMethod value selected "window-length", then you can specify the length of the data window using the property WindowLength.
If as a resolution method FrequencyResolutionMethod value selected "rbw", then the algorithm determines the length of the data window using the following equation: .
It then splits the input signal into several data segments processed using the window.
Most window functions have a greater impact on the data in the center of the segment than on the data at the edges, resulting in information loss.
To reduce this loss, individual data segments are usually overlapped in time.
For each segment processed using the window, a periodogram is calculated by calculating the discrete Fourier transform.
Then the square of the modulus of the result is calculated and divided by :
where is the normalization factor for the power in the window function and is defined as:
The spectrum analyzer calculates and plots the power spectrum, power spectral density, and RMS value using a modified periodogram calculation method.
To determine the calculation of the power spectrum for the Welch method, the spectrum analyzer averages the results of the periodograms for the latter data segments.
Averaging reduces the variance compared to the original one -a point segment of data.
For more information about averaging methods, see The averaging method.
The spectrum analyzer calculates the spectral power density using:
The power spectrum is the product of the spectral power density and the resolution band:
The spectrum analyzer displays the power in the form of a spectrogram in the mode "spectrogram".
Each line of the spectrogram represents a periodogram.
The time resolution of each line is , which is the minimum achievable resolution.
To achieve the required resolution, it may be necessary to combine several periodograms.
Then, using interpolation, non-integer values are calculated. .
On the spectrogram screen, time scrolls from top to bottom, so the most recent data is displayed at the top of the screen.
The offset shows the time at which the center of the most recent line of the spectrogram was located.
The spectrum analyzer uses a certain number of samples to calculate the spectrum.
This value is directly related to the resolution band () using the following equation:
or with the length of the window () using the equation:
If as a resolution method FrequencyResolutionMethod value selected "rbw", then the window length is determined by the formula:
If as a resolution method FrequencyResolutionMethod value selected "window-length" the algorithm uses the window length value specified in the property WindowLength.
Percentage of overlap (Op)
Details
Percentage of overlap — this is the value specified in the property OverlapPercent.
As the percentage of overlap increases, the spectrum analyzer requires fewer new input samples to calculate a new spectral update.
0%
100
50%
50
80%
20
Normalized Effective Noise Bandwidth (NENBW)
Details
Normalized Effective Noise Bandwidth, ) is a window parameter that measures the noise characteristics of the window.
Meaning It is determined using the window length and its coefficients and is given by the following equation:
where denotes the vector of window coefficients, and — the length of the window.
For more information about how the algorithm determines the window length, see Spectrum calculation — the Welch method.
The lowest value has a rectangular window equal to 1.
All other windows are more important. .
For example, the Hanna window has a value approximately 1.5.
Resolution Band (RBW)
Details
Resolution Band controls the spectral resolution of the displayed signal. Meaning defines the interval between the frequencies that the spectrum analyzer can resolve. A lower value provides higher spectral resolution and reduces noise levels, meaning the spectrum analyzer can resolve frequencies located closer to each other. However, this leads to an increase in the scan time.
The resolution band can be set using the property RBW in Hz.
"auto" — the spectrum analyzer determines the appropriate resolution band to ensure the presence of 1024 bandwidth resolution intervals in a given frequency range.
In this case, the spectrum analyzer calculates RBW using the formula:
"property" — the spectrum analyzer calculates the number of samples using the formula:
where
— the sampling frequency of the input signal, set by the property SampleRate in Hz;
— specified in RBW The value of the resolution band must be such that there are at least two RBW intervals in the specified frequency range.
The ratio of the total range to RBW must be greater than two:
;
— the range in which the spectrum analyzer calculates and plots the spectrum.
If specified FrequencyResolutionMethod = "num-frequency-bands", then the resulting resolution bandwidth will be:
Nyquist frequency range
Details
When constructing a two-way spectrum, when PlotAsTwoSidedSpectrum = true, the Nyquist frequency range is in Hz.
The spectrum analyzer calculates a moving average using one of the following methods:
The video band spectrum analyzer uses a low—pass filter in the time domain to smooth out noise in the signal. Video Band Filter () smooths the curve and reduces noise, and the spectrum analyzer applies this filter to the data before displaying it.
The video band is the bandwidth of a low—pass filter that a spectrum analyzer uses to average or smooth out noise in a signal before displaying it. The spectrum analyzer calculates the video band using the following formula:
The video band does not affect the noise level (noise threshold), but only increases the signal-to-noise ratio and smoothes the noise curve. When decreasing the value The signal-to-noise ratio is improving.
The cutoff frequency of the video band filter is determined by the formula:
where
— sampling rate of the input signal;
— the number of FFT points.
Exponential — The moving average algorithm uses exponential weighting to update the weights and recursively calculate the moving average for each incoming vector. using the following recursive equations:
where
— the coefficient of forgetting;
— the weight factor applied to the current vector ;
— current vector ;
— the moving average up to the previous vector ;
— the influence of previous vectors on average;
— a moving average that includes the current vector .