Borrar filtros
Borrar filtros

How to Normalize a fft to plot in frequency domain?

352 visualizaciones (últimos 30 días)
Syed Rumman
Syed Rumman el 14 de Sept. de 2017
Comentada: Star Strider el 1 de Nov. de 2021
When I plot the frequency domain the power is not 3 and 5 as I expect. I read the documentation for fft() and cannot figure out how to normalize my fft properly. Can someone explain the procedure to normalize the cosines and a Gaussian wave? Thanks
clear all;
%generate the signal
t = 0:1/2000:.02;
x = 3*cos(2*pi*60*t) + 5*cos(2*pi*200*t);
%sample the signal
fs = 1000;
t1000 = 0:1/fs:.02; % number of sample points
n1000 = 0:length(t1000)-1; % number of intervals
x1000 = 3*cos(2*pi*60*n1000/1000) + 5*cos(2*pi*200*n1000/1000) ; %cos(2*pi*60*n*ts);
%Compute FT
z = fftshift(fft(x1000));
f = -fs/2: fs/(length(n1000)-1): fs/2 ;
%plot time domain
figure
subplot(2,1,1)
plot(t,x)
hold on;
grid on;
stem(t1000, x1000, 'filled', 'r', 'LineWidth', 2);
%plot freq domain
subplot(2,1,2);
plot(f,abs(z)); %normalization??
grid on;
xticks(-500:50:500);
xlim([-300 300]);

Respuesta aceptada

Star Strider
Star Strider el 14 de Sept. de 2017
I am not certain what you intend by ‘normalise’. You need to scale it by dividing the fft result by the length of the time-domain signal:
z = fftshift(fft(x1000)/length(x1000));
This ‘normalises’ the result, correcting for the total energy in the time-domain signal. (You can use the numel function instead of length for a vector. Read about both to understand where each is appropriate.)
Note that you are using the two-sided Fourier transform, so the signal intensity will be equally divided between the negative frequencies and positive frequencies. In a one-sided Fourier transform, correct for this by multiplying the fft output by 2 to reproduce the amplitude of the original signals.
  6 comentarios
Mustafa Rifat
Mustafa Rifat el 1 de Nov. de 2021
Hello, If we perform fft2, should we normalize dividing by length(x)*length(y)?
Star Strider
Star Strider el 1 de Nov. de 2021
@Mustafa Rifat — Apparently not. The discussion in the fft2 secton on 2-D Fourier Transform does not normalise by the lengths or the number of elements in the matrix, however a similar discussion on Discrete Fourier Transform of Vector in the fft documentation, does.
I admit that I have never thought about this before, because I infrequently use fft2.
There is nothing wrong with experimenting to see if dividing by numel(A), where ‘A’ is the matrix, gives the desired result.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Fourier Analysis and Filtering en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by