我有一個輸入信號,我計算了它的FFT。之後,我只需要在頻率帶寬上計算其均方根值,而不是針對所有頻譜。獲得每個頻率的RMS
我使用Parseval定理求解了整個頻譜的RMS計算,但是如何計算這種RMS「選擇性」?我已經正確地計算了索引以獲得三個感興趣的頻率(F0,FC,F1),但是當將RMS應用於該頻帶時,似乎Parseval的定理不是完整的。
我收到一個獨特的10 KHz頻率,從FFT總頻譜的RMS是正確的,但其RMS選擇性在10 KHz頻率給我一個錯誤的結果(-0.4V從RMS正確的一個),應該給我幾乎相同因爲我在頻譜中只有一個頻率。在這裏,您可以看到我的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;
}
你以前沒有問過這個問題嗎? [從FFT獲取RMS](http://stackoverflow.com/questions/43452138/getting-rms-from-fft)和[從FFT獲取RMS](http://stackoverflow.com/questions/43363860/get-rms -from-fft)? –