【问题标题】:Get RMS at each Frequency获取每个频率的 RMS
【发布时间】:2017-04-21 07:01:01
【问题描述】:

我有一个输入信号,我计算了它的 FFT。之后,我只需要在一个频率带宽上计算它的 RMS,而不是针对所有频谱。

我应用 Parseval 定理解决了整个频谱的 RMS 计算,但我如何计算这种“选择性”的 RMS?我已经正确计算了索引以获得三个感兴趣的频率(F0、FC、F1),但是当将 RMS 应用于此带宽时,似乎 Parseval 定理不成立。

我收到一个独特的 10 KHz 频率,来自 FFT 总频谱的 RMS 是正确的,但它在 10 KHz 频率下的 RMS 选择性给了我一个错误的结果(从 RMS 正确的一个 -0.4V),应该给我几乎相同的结果因为我在频谱中只有一个频率。在这里你可以看到我的 RMS 选择性计算:

 public static double RMSSelectiveCalculation(double[] trama, double samplingFreq, double F0, double Fc, double F1)
    {
    //Frequency of interest          
        double fs = samplingFreq;   // Sampling frequency
        double t1 = 1 / fs;          // Sample time
        int l = trama.Length;       // Length of signal
        double rmsSelective = 0;
        double ParsevalB = 0;
        double scalingFactor = fs;
        double dt = 1 / fs;

        // We just use half of the data as the other half is simetric. The middle is found in NFFT/2 + 1
        int nFFT = (int)Math.Pow(2, NextPow2(l));
        double df = fs / nFFT;
        if (nFFT > 655600)
        { }

        // Create complex array for FFT transformation. Use 0s for imaginary part
        Complex[] samples = new Complex[nFFT];
        Complex[] reverseSamples = new Complex[nFFT];
        double[] frecuencies = new double[nFFT];
        for (int i = 0; i < nFFT; i++)
        {
            frecuencies[i] = i * (fs / nFFT);

            if (i >= trama.Length)
            {
                samples[i] = new MathNet.Numerics.Complex(0, 0);
            }
            else
            {
                samples[i] = new MathNet.Numerics.Complex(trama[i], 0);
            }
        }

        ComplexFourierTransformation fft = new ComplexFourierTransformation(TransformationConvention.Matlab);
        fft.TransformForward(samples);
        ComplexVector s = new ComplexVector(samples);
        //The indexes will get the index of each frecuency
        int f0Index, fcIndex, f1Index;
        double k = nFFT / fs;
        f0Index = (int)Math.Floor(k * F0);
        fcIndex = (int)Math.Floor(k * Fc);
        f1Index = (int)Math.Ceiling(k * F1);

        for (int i = f0Index; i <= f1Index; i++)
        {
            ParsevalB += Math.Pow(Math.Abs(s[i].Modulus / scalingFactor), 2.0);
        }

        ParsevalB = ParsevalB * df;

        double ownSF = fs / l; //This is a own scale factor used to take the square root after

        rmsSelective = Math.Sqrt(ParsevalB * ownSF);

        samples = null;
        s = null;

        return rmsSelective;

    }

【问题讨论】:

标签: c# indexing fft frequency rms


【解决方案1】:

功率谱密度 PSD 的估计值由 FFT 幅度的平方给出。

具有一定带宽的部分的 RMS 是该部分 PSD 的面积的根。

因此,实际上,只需将 FFT 的绝对值在较低频率和较高频率之间积分即可。

MATLAB example

【讨论】:

  • 请看我的回答
  • “所以实际上,只需将 FFT 的绝对值在低频和高频之间积分即可。”这是不正确的。您需要在较低频率和较高频率之间积分 FFT 的幅度平方,然后取平方根。积分绝对值会使您的结果产生偏差。此外,计算光谱中每个点的绝对值需要对每个点求平方根,因此即使它是正确的,也比最后只求平方根要慢。
猜你喜欢
  • 2014-04-11
  • 1970-01-01
  • 1970-01-01
  • 2012-08-04
  • 1970-01-01
  • 2015-11-21
  • 1970-01-01
  • 2011-05-20
相关资源
最近更新 更多