主要的Content

估计the Power Spectrum in金宝app

The power spectrum (PS) of a time-domain signal is the distribution of power contained within the signal over frequency, based on a finite set of data. The frequency-domain representation of the signal is often easier to analyze than the time-domain representation. Many signal processing applications, such as noise cancellation and system identification, are based on the frequency-specific modifications of signals. The goal of the power spectral estimation is to estimate the power spectrum of a signal from a sequence of time samples. Depending on what is known about the signal, estimation techniques can involve parametric or nonparametric approaches and can be based on time-domain or frequency-domain analysis. For example, a common parametric technique involves fitting the observations to an autoregressive model. A common nonparametric technique is the periodogram. The power spectrum is estimated using Fourier transform methods such as the Welch method and the filter bank method. For signals with relatively small length, the filter bank approach produces a spectral estimate with a higher resolution, a more accurate noise floor, and peaks more precise than the Welch method, with low or no spectral leakage. These advantages come at the expense of increased computation and slower tracking. For more details on these methods, seeSpectral Analysis。您还可以使用其他技术,例如最大熵方法。

在Si金宝appmulink中®,您可以使用该动态信号进行实时光谱分析Spectrum Analyzer堵塞。您可以在光谱分析仪中查看光谱数据。要获取最后的光谱数据以进行进一步处理,请创建一个谱素化素化合物对象并运行getspectrumdatafunction on this object. Alternately, you can use the谱估计block from thedspspect3计算功率谱的库,并阵列图块到view the spectrum.

估计the Power Spectrum Using the Spectrum Analyzer

您可以使用该信号的功率谱(PS)使用Spectrum Analyzer堵塞。The PS is computed in real time and varies with the input signal, and with changes in the properties of theSpectrum Analyzer堵塞。You can change the dynamics of the input signal and see what effect those changes have on the spectrum of the signal in real time.

The modelEX_PSD_SA将嘈杂的正弦波信号馈送到Spectrum Analyzer堵塞。The sine wave signal is a sum of two sinusoids: one at a frequency of 5000 Hz and the other at a frequency of 10,000 Hz. The noise at the input is Gaussian, with zero mean and a standard deviation of 0.01.

Open and Inspect the Model

To open the model, enterEX_PSD_SAin the MATLAB®命令提示符。

Here are the settings of the blocks in the model.

Block 参数更改 块的目的
正弦波1
  • 频率到5000

  • 采样时间至1/44100

  • Samples per frame到1024

Sinusoid signal with frequency at 5000 Hz

正弦波2
  • 频率到10000

  • Phase offset (rad)到10

  • 采样时间至1/44100

  • Samples per frame到1024

Sinusoid signal with frequency at 10000 Hz

Random Source
  • Source typeGaussian

  • Variance到1E-4

  • 采样时间至1/44100

  • Samples per frame到1024

Random Sourceblock generates a random noise signal with properties specified through the block dialog box
Add 标志列表+++ Addblock adds random noise to the input signal
Spectrum Analyzer

点击theSpectrum Settingsicon。A pane appears on the right.

  • 在里面主要的optionspane, underType, 选择Power。UnderMethod, 选择Filter bank

  • 在里面跟踪选项pane, clear theTwo-sided spectrumcheck box. This shows only the real-half of the spectrum.

  • If needed, select theMax-hold trace最小痕迹复选框。

点击theConfiguration Propertiesicon并设置Y限度(最低)as-100Y-limits (Maximum)as40

Spectrum Analyzerblock shows the Power Spectrum Density of the signal

Play the model. Open theSpectrum Analyzer块到view the power spectrum of the sine wave signal. There are two tones at frequencies 5000 Hz and 10,000 Hz, which correspond to the two frequencies at the input.

RBW, the resolution bandwidth is the minimum frequency bandwidth that can be resolved by the spectrum analyzer. By default,RBW (Hz)is set to汽车。在里面汽车mode, RBW is the ratio of the frequency span to 1024. In a two-sided spectrum, this value isFs/1024, while in a one-sided spectrum, it is(Fs/2)/1024。频谱分析仪EX_PSD_SAis configured to show one-sided spectrum. Hence, the RBW is (44100/2)/1024 or 21.53 Hz.

使用此值的RBW,用于计算一个光谱更新的输入样本数量由Nsamples= FS/RBW, which is 44100/21.53 or 2048.

RBW calculated in this mode gives a good frequency resolution.

要区分显示屏中的两个频率,两个频率之间的距离必须至少为RBW。在此示例中,两个峰之间的距离为5000 Hz,大于RBW。因此,您可以清楚地看到峰值。将第二个正弦波的频率从10000 Hz更改为5015 Hz。两个频率之间的区别小于RBW

On zooming, you can see that the peaks are not distinguishable.

To increase the frequency resolution, decreaseRBW到1 Hz and run the simulation.

On zooming, the two peaks, which are 15 Hz apart, are now distinguishable

当您增加频率分辨率时,时间分辨率会降低。为了在频率分辨率和时间分辨率之间保持良好的平衡,请更改RBW (Hz)汽车

Change the Input Signal

When you change the dynamics of the input signal during simulation, the power spectrum of the signal also changes in real time. While the simulation is running, change the频率正弦波1块到8000和clickApply。光谱分析仪输出中的第二个音调转移到8000 Hz,您可以实时看到更改。

Change the Spectrum Analyzer Settings

When you change the settings in theSpectrum Analyzerblock, the effect can be seen on the spectral data in real time.

When the model is running, in the痕迹选项窗格Spectrum Analyzerblock, change the规模Log。The PS is now displayed on a log scale.

For more information on how theSpectrum Analyzer设置会影响功率谱数据,请参见“算法”部分Spectrum Analyzer块参考页。

转变the Power Between Units

光谱分析仪提供了三个单位来指定功率谱密度:瓦特/Hz,dBm/Hz, 和dBW/Hz。相应的力量单位是瓦特,dBm, 和dBW。For electrical engineering applications, you can also view the RMS of your signal inVRMS或者dBV。The default spectrum type isPowerindBm

将瓦特的功率转换为DBW和DBM

电源dBWis given by:

P d B W = 10 log 10 ( p o w e r i n w a t t / 1 w a t t )

电源dBmis given by:

P d B m = 10 log 10 ( p o w e r i n w a t t / 1 m i l l i w a t t )

For a sine wave signal with an amplitude of 1 V, the power of a one-sided spectrum in瓦特is given by:

P W a t t s = A 2 / 2 P W a t t s = 1 / 2

In this example, this power equals 0.5 W. Corresponding power in dBm is given by:

P d B m = 10 log 10 ( p o w e r i n w a t t / 1 m i l l i w a t t ) P d B m = 10 log 10 ( 0.5 / 10 - 3 )

Here, the power equals 26.9897 dBm. To confirm this value with a peak finder, click工具>Measurements>峰查找器

For a white noise signal, the spectrum is flat for all frequencies. The spectrum analyzer in this example shows a one-sided spectrum in the range [0 Fs/2]. For a white noise signal with a variance of 1e-4, the power per unit bandwidth (PUnitBandWidth) is 1e-4. The total power of white noise inwattsover the entire frequency range is given by:

P w h i t e n o i s e = P u n i t b a n d w i d t h * n u m b e r o f f r e q u e n c y b i n s , P w h i t e n o i s e = ( 10 - 4 ) * ( F s / 2 R B W ) , P w h i t e n o i s e = ( 10 - 4 ) * ( 22050 21.53 )

频率箱的数量是总带宽与RBW的比率。对于单侧频谱,总带宽是采样率的一半。在此示例中,RBW为21.53 Hz。有了这些值,白噪声的总功率watts为0.1024 W.在DBM中,可以使用白噪声的功率来计算10*log10(0.1024/10^-3),等于20.103 dbm。

将瓦特电源转换为DBFS

If you set the spectral units toDBFS并设置完整的比例(FullScaleSource) 到汽车, power inDBFS计算为:

P d B F S = 20 log 10 ( P w a t t s / F u l l _ S c a l e )

where:

  • Pwatts是瓦特的力量

  • 对于双重和浮动信号,full_scale是输入信号的最大值。

  • For fixed point or integer signals,full_scaleis the maximum value that can be represented.

如果您指定手动完整比例(设置FullScaleSource财产), power inDBFSis given by:

P F S = 20 log 10 ( P w a t t s / F S )

WhereFSis the full scaling factor specified in theFullScaleproperty.

For a sine wave signal with an amplitude of 1 V, the power of a one-sided spectrum in瓦特is given by:

P W a t t s = A 2 / 2 P W a t t s = 1 / 2

In this example, this power equals 0.5 W and the maximum input signal for a sine wave is 1 V. The corresponding power in dBFS is given by:

P F S = 20 log 10 ( 1 / 2 / 1 )

在这里,功率等于-3.0103。要在频谱分析仪中确认此值,请运行以下命令:

Fs = 1000;%采样频率sinef = dsp。SineWave('SampleRate',Fs,'SamplesPerFrame',100); scope = dsp.SpectrumAnalyzer('SampleRate',Fs,... 'SpectrumUnits','dBFS','PlotAsTwoSidedSpectrum',false) %% for ii = 1:100000 xsine = sinef(); scope(xsine) end
然后,单击工具>Measurements>峰查找器

转变the Power in dBm to RMS in Vrms

电源dBmis given by:

P d B m = 10 log 10 ( p o w e r i n w a t t / 1 m i l l i w a t t )

RMS中的电压由:

V r m s = 10 P d B m / 20 10 - 3

From the previous example, PdBmequals 26.9897 dBm. The VRMS被计算为

V r m s = 10 26.9897 / 20 0.001

which equals 0.7071.

To confirm this value:

  1. ChangeTypeRMS

  2. Open the peak finder by clicking工具>Measurements>峰查找器

估计Power Spectrum Using the谱估计Block

Alternately, you can compute the power spectrum of the signal using the谱估计块INthedspspect3library. You can acquire the output of the spectrum estimator and store the data for further processing.

Replace theSpectrum Analyzer块INEX_PSD_SA谱估计街区,然后是阵列图堵塞。To view the model, enterEX_PSD_ESTIMATORBLOCKin the MATLAB command prompt. In addition, to access the spectral estimation data in MATLAB, connect theTo Workspace(Simulink)块到the output of the谱估计堵塞。这是对设置的更改谱估计block and the阵列图堵塞。

Block 参数更改 块的目的
谱估计

  • 频率resolution methodNumber of frequency bands

  • 频率range片面

Computes the power spectrum of the input signal using the filter bank approach.
阵列图

点击View

  • select风格。在里面风格window, select thePlot typeas楼梯

  • selectConfiguration Properties。在里面Configuration Properties window, on the主要的tab, set theSample incrementas44.1/1024。On the展示tab, changeX-label频率(kHz),Y标签Power (dBm)。For details, see the section 'Convertx- 代表频率的轴。另外,设置Y限度(最低)-100Y-limits (Maximum)40

展示s the power spectrum data.

The spectrum displayed in the阵列图块类似于在Spectrum Analyzer块INEX_PSD_SA

The filter bank approach produces peaks that have very minimal spectral leakage.

转变x- 轴表示频率

By default, the阵列图块绘制了PS数据相对于每个帧的样品数量。X轴上的点数等于输入帧的长度。Spectrum Analyzer绘制了PS数据相对于频率的数据。对于单侧频谱,频率在[0 fs/2]范围内变化。对于双面光谱,频率在[-FS/2 FS/2]范围内变化。转换x- 从基于样本到频率的阵列图的轴,请执行以下操作:

  • 点击on theConfiguration Propertiesicon。On主要的tab, setSample incrementFs/FrameLength

  • 对于单侧频谱,设置X-offset0

  • For a two-sided spectrum, setX-offset-Fs/2

In this example, the spectrum is one-sided and hence, theSample incrementX-offsetare set to44100/10240, respectively. To specify the frequency inkHz,设置Sample increment44.1/1024

实时处理

The output of the谱估计块包含光谱数据,可用于进一步处理。数据可以实时处理,也可以使用该数据存储在工作空间中To Workspace堵塞。此示例将光谱数据写入工作区变量估计

相关话题