fast fourier tranform gives unequals amplitudes for frequencies with initially (before the fft) the same amplitude

1 visualización (últimos 30 días)
Hi, I tried to find all the different frequencies in a sums of sinus using the fast fourier transform function in MATLAB. The fft function gives me the right frequencies, but with differents amplitude, even if all the amplitudes are equal to 1 (see the y vector). I really dont understand what im doing wrong. Thanks you very much for any information, don't hesitate to ask if you need more details about the question.
Here is the code I ran :
f = 3*10^6; %sampling frequency
t = 0:f^-1:1*10^-2-1*f^-1; %time vector
y = sin(2*pi*(1000*10^-9)^-1*t) + sin(2*pi*(1300*10^-9)^-1*t) + sin(2*pi*(900*10^-9)^-1*t) + sin(2*pi*(800*10^-9)^-1*t) + sin(2*pi*(700*10^-9)^-1*t) ;
Y = fft(y, 2^nextpow2(length(t)));
Amp = Y.*conj(Y)/length(Y);
frequ = f/length(Y)*(0:length(Y)/2);
plot(frequ,Amp(1:(length(Y))/2+1))

Respuestas (1)

Walter Roberson
Walter Roberson el 4 de Jul. de 2020
sin(2*pi*(900*10^-9)^-1*t)
(900*10^-9)^-1 is 1111111.11111111 Hz. But your sampling frequency is 32768. You have about 33.9 cycles of 1111111.11111111 Hz between every two adjacent samples. You have heavy aliasing.
Your sampling frequency also does not evenly divide your source frequencies, so your source frequencies are not going to fit into just one bin. The distribution between adjacent bins is going to depend on the exact frequency and ratios. So possibly one pair of adjacent bins might get hit 10% / 90% and another pair of adjacent bins might get hit 50% / 50%, but this does not mean that the amplitude is nearly twice as much at one frequency than the other: it just means that there is a bad fit between frequencies and binning.
  3 comentarios
Walter Roberson
Walter Roberson el 4 de Jul. de 2020
I did miss the scaling by t. Your maximum t is 0.00999966666666667 so you are correct that you do not have aliasing.
However, you do have different number of bins for each frequency and that is going to lead to the data being split irregularly. If your frequencies were 1024, 1310.72, 910.2, then you would have less irregularity in the bin allocation.
Henri Paquette
Henri Paquette el 4 de Jul. de 2020
Can I ask you how did you came up with theses values for the frequencies? Also, is there a way I can get the correct amplitude, after the fft, using arbitrary frequencies? Thanks a lot for your help.

Iniciar sesión para comentar.

Etiquetas

Productos


Versión

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by