Results 1 to 2 of 2

Math Help - Matlab fft output dB reference value

  1. #1
    Newbie
    Joined
    Sep 2009
    Posts
    1

    Matlab fft output dB reference value

    Hi,

    I'm using a version of daqacquire to acquire a sample of sound data. This program also uses daqdocfft to perform a fourier transform, allowing me to view the frequencies that are present in my data sample.

    My problem is that I don't understand how the function is calculating the magnitude of the output values of the fourier transform. The code is as follows:

    xfft = abs(fft(data));

    % Avoid taking the log of 0.
    index = find(xfft == 0);
    xfft(index) = 1e-17;

    mag = 20*log10(xfft);
    mag = mag(1:floor(blocksize/2));
    f = (0:length(mag)-1)*Fs/blocksize;
    f = f(;


    The line 'mag = 20*log10(xfft);' seems to assign a dB value to the output, referenced to 1. If this was the case, I would expect a plot of the spectrum to have negative magnitudes, since they would all be less than 1. However for the data I'm trying to analyse, the spectrum magnitudes range from -40dB to 80dB.

    Ideally what I would like to do is assign a reference value to the peak magnitude in the spectrum, so that it would be set to 0dB, and all other values would be relative to it.

    I'd be grateful if anyone could tell me how to do this, or at least explain to me what this code is using as 0dB, and what value is being referenced.

    Thanks for any help.
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by ricicle View Post
    Hi,

    I'm using a version of daqacquire to acquire a sample of sound data. This program also uses daqdocfft to perform a fourier transform, allowing me to view the frequencies that are present in my data sample.

    My problem is that I don't understand how the function is calculating the magnitude of the output values of the fourier transform. The code is as follows:

    xfft = abs(fft(data));

    % Avoid taking the log of 0.
    index = find(xfft == 0);
    xfft(index) = 1e-17;

    mag = 20*log10(xfft);
    mag = mag(1:floor(blocksize/2));
    f = (0:length(mag)-1)*Fs/blocksize;
    f = f(;


    The line 'mag = 20*log10(xfft);' seems to assign a dB value to the output, referenced to 1. If this was the case, I would expect a plot of the spectrum to have negative magnitudes, since they would all be less than 1. However for the data I'm trying to analyse, the spectrum magnitudes range from -40dB to 80dB.

    Ideally what I would like to do is assign a reference value to the peak magnitude in the spectrum, so that it would be set to 0dB, and all other values would be relative to it.

    I'd be grateful if anyone could tell me how to do this, or at least explain to me what this code is using as 0dB, and what value is being referenced.

    Thanks for any help.
    Remember there is no fixed convention for normalsing the FFT, you need to check what the normalisation is for what ever you use, if you are lucky the documentation will tell you what normalisation Matlab uses.

    Try:

    mag=mag-max(mag);

    CB
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Book reference?
    Posted in the Advanced Math Topics Forum
    Replies: 0
    Last Post: September 9th 2010, 09:06 AM
  2. A little help with reference angles.
    Posted in the Trigonometry Forum
    Replies: 5
    Last Post: January 24th 2010, 09:40 PM
  3. Using Reference Angles
    Posted in the Trigonometry Forum
    Replies: 1
    Last Post: April 5th 2009, 02:59 PM
  4. Frames of reference
    Posted in the Advanced Applied Math Forum
    Replies: 1
    Last Post: October 31st 2008, 08:09 AM
  5. Reference Angles...
    Posted in the Trigonometry Forum
    Replies: 4
    Last Post: August 15th 2008, 11:56 PM

Search Tags


/mathhelpforum @mathhelpforum