2017-04-21 34 views
0

入力信号があり、FFTを計算しました。その後、すべてのスペクトルではなく、周波数の帯域でのみRMSを計算する必要があります。各周波数でRMSを取得

Parsevalの定理を適用して、スペクトル全体のRMS計算を解決しましたが、このようなRMSの「選択的」をどのように計算しますか?私は関心のある3つのフリークエンシー(F0、FC、F1)を得るために正確に計算されたインデックスを持っていますが、このバンドにRMSを適用すると、Parsevalの定理は保持されていないようです。

固有の10KHzの周波数を受信しましたが、FFTの全スペクトルからのRMSは正しいですが、10KHzの周波数でRMSを選択すると、間違った結果が得られます(RMSから正しく-0.4Vになります)。結果として、私はスペクトル内で1つのfrecuencyしか得られなかった。ここでは、選択的な計算私の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; 

    } 
+0

あなたは、例えば、数回前にこの同じ質問をしなかったの[FFTからRMSを取得する](http://stackoverflow.com/questions/43452138/getting-rms-from-fft)と[FFTからRMSを取得する](http://stackoverflow.com/questions/43363860/get-rms -from-fft)? –

答えて

0

パワースペクトル密度PSDの推定値は、FFTの大きさの二乗で与えられます。

特定の帯域幅を持つセクションのRMSは、そのセクションのPSDの領域のルートです。

実際には、下限周波数と上限周波数との間でFFTの絶対値を積分するだけです。

MATLAB example

+0

私の答えを見てください –