Normalisation of FFT not consistent.
Afficher commentaires plus anciens
Hi, I am having a few issues normalising my frequency and amplitude for a test FFT I am trying to code. I think it boils down to my understanding of the relationship between signal length, sampling frequency etc.
Below is an example of my code for one set of configuration parameters. We are looking to convert the frequency space results into the physical space. Hence I want to recover a 20Hz frequency and an amplitude of 3 from a FFT.
clc; clear all; close all;
%%Creating test data to ensure FFT is working correctly
Ls = 10; % Length of signal
ds = 10000 % discrete data points
var = linspace(0,Ls,ds);
% Signal Frequencies and amplitudes
kx = 20; ax = 3;
% Signal creation
D = ax*cos(2*pi*kx*var);
%%FFT Stage
Fs = 1000; % Sampling Frequency
n = 2^nextpow2(Fs);
Y = fft(D,n);
% Normalising Y amplitude by number of sampling points
Y = abs(Y/n);
%%Plotting
% Creating vector f that transforms FFT frequency bins to frequency space
% defined by var.
f = linspace(0,1,length(Y))*Fs;
plot(f,Y)
xlabel('Frequency')
ylabel('Amplitude')
This produces the plot:

Which is giving me the correct frequency but not the right amplitude (I am not concerned with the one sided spectrum at the moment).
If I increase my sampling rate by an order of magnitude to Fs = 10000, my frequency changes and my amplitude is still not correct.

I have tried a few permutations of scaling behaviour, but cannot isolate the exact problem. What is the relationship between my signal length (Ls), the resolution of the data over that length (ds), and the sampling frequency used for FFT of that data (Fs)?
Also, how do I best go about increasing the accuracy of FFT so that my frequency is as close and sharp at 20Hz with magnitude exactly 3?
Please help me signal processing gurus! I am eager to learn!
Réponse acceptée
Plus de réponses (1)
David Goodmanson
le 2 Déc 2017
0 votes
Good question. I didn't take a course in DSP, so I don't have a textbook recommendation from experience. Rodriguez mentions the problem about the one extra array point at least twice (although not in terms of a linspace function) but he does not really emphasize it. The book has a lot of good information but it is 30 years old, kind of lab oriented, and pretty dense in the text. I wouldn't recommend rushing off and buying a copy. I have not looked at the Schaum's Outlines DFT book but Schaum's is usually pretty good (their complex variables and topology books are excellent), they have lots of solved problems and the price is right. I'm sure there must be a library you can go graze in, but if I had to buy a book sight unseen that would be it.
Catégories
En savoir plus sur Parametric Spectral Estimation dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!