slight difference in magnitude of signal between time and frequency domain

2 次查看(过去 30 天)
hi all,
this has been puzzling me for some time now and I would be thankful if you could lead me to the right direction of solving this.
I am reading a .wav file using audioread() and saving the samples in a vector y. I am then multiplying the samples in y by a factor of 1.18 in order to bring them to a desired level.
I am then running y through the following function:
NFFT = 2^nextpow2(length(y)); %improves performance of fft
Y = (1/NFFT)*fft(y,NFFT); %multiply by 1/NFFT to compensate matlab scaling...
freqAxis = fs/2*linspace(0,1,NFFT/2); %construct the frequency axes
Y = 2*Y(1:(NFFT/2)); %keep the first half of the data, multiply by 2 to compensate for lost energy
When I am checking the max(y) then I get the expected value of 1.18. When I am checking the maximum of the frequency representation of y by using max(abs(Y)) then i am getting a value of about 0.97.
This creates big problems to my application as the plot of the fft always returns with a few dBs of error as compared to the real magnitude of the signal.
I wonder if there is something wrong with my implementation or if I am totally missing something here.
thank you for your time, Dimitris

采纳的回答

Star Strider
Star Strider 2016-8-9
This is incorrect:
Y = (1/NFFT)*fft(y,NFFT); %multiply by 1/NFFT to compensate matlab scaling...
Divide by the length of the original signal, not the padded signal to correct for the energy in the signal. Scaling has nothing at all to do with it. See the R2015a documentation for fft for details. That documentation should answer your other questions as well.

更多回答(1 个)

Dimitris
Dimitris 2016-8-9
thank you very much for your input. this fixes my problem!

类别

Help CenterFile Exchange 中查找有关 Digital Filter Analysis 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by