Trying to do a Fourier Transform on a random but discrete time-domain signal, so that I can look into the dominant frequencies etc, but I'm struggling to plot it correctly.
The data has been gathered using a vibration-sensor app on my phone, which can also do FT within (which I am assuming to be fairly accurate), so I have been comparing the FT from the app to the FT from MATLAB. The lines are similar in shape, but the MATLAB one is mirrored, possibly stretched, and the scaling is totally off.
Does anyone know of any guides or tutorials on how to correctly display a FFT?
This is my code so far, the xls file is simply a column of the accelerations. Anything look particularly wrong?
Any help would be great!
clc
clear
T = 5.57; % Sampling time (s)
L = 512; % Length of signal (No. samples taken)
Fs = L/T; % Sampling frequency (Hz)
a = xlsread ('Randomshake19.02.xlsx', 'X-Time'); % X-plane accelerations (m/s^2)
t = linspace (0, T, L); % Time vector
NFFT = 2^nextpow2(L); % Number of points used to form FFT. Next power of 2 from length of y
X = linspace (1, Fs, L);
Y = fft(a, NFFT);
subplot (1, 2, 1) % Time domain plot
plot (t, a)
xlabel('Time (s)')
ylabel('Magnitude of Acceleration (m/s^2)')
subplot (1, 2, 2) % Frequency domain plot
plot (X,abs(Y))
xlabel('Frequency (Hz)')
ylabel('Magnitude of Acceleration (m/s^2)')