how to obtain the frequency when doing the fourier trasform
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
giacomo labbri
el 2 de Jul. de 2020
Comentada: Star Strider
el 3 de Jul. de 2020
Hi,
I am applying the fast fourier trasform to a timeseries. When I plot the transform (or better its absolute value) I would like to have on the x axis a range of frequency but I am not sure how to calculate that.
I am working with data that are each minute and are registered in a timetable.
Thanks in advance,
Giacomo
0 comentarios
Respuesta aceptada
Star Strider
el 2 de Jul. de 2020
Assuming that the data are regularly sampled, so that the sampling intervals are the same for all of them, I usually do something like this:
y = ...; % Signal (Vector Or Matrix)
t = ...; % Time Vector
Fs = 1/mean(diff(t)); % Sampling Frequency
Fn = Fs/2; % Nyquist Frequency
ym = y - mean(y); % Subtract Column Means From All Columns (Eliminates D-C Offset Effect)
L = numel(t); % Signal Lengths
FTy = fft(ym)/L; % Fourier Transform (Scaled For Length)
Fv = linspace(0, 1, fix(L/2)+1)*Fn; % Frequency Vector
Iv = 1:numel(Fv); % Index Vector
figure
plot(Fv, abs(FTy(Iv,:))*2)
grid
This calculates and plots a one-sided Fourier transform. You will need to supply ‘t’ and ‘y’. The code should be reasonably robust.
.
2 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Discrete Fourier and Cosine Transforms en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!