I have a vibration data in time domain and want to convert it to frequency domain.However my data is not uniformly sampled, so I am having trouble applying fast fourier transform to it. I have attached my excel data file.Can you guys please help
MATLAB: How to find FFT of a non-uniformly sampled data
fft
Related Solutions
This works:
D = load('Lamiae Lammy VNE.txt');t = D(:,1); % Original Time Vector
v = D(:,2:end); % Original Voltage Matrix
L = size(t,1); % Date Length
tr = linspace(min(t), max(t), L); % Time Vector For Reseampling
vr = resample(v, tr); % Resampled Voltages
Ts = tr(2)-tr(1); % Sampling Time
Fs = 1/Ts; % Sampling Frequency
Fn = Fs/2; % Nyquist Frequency
FTvr = fft(vr)/L; % Fourier Transform
Fv = linspace(0, 1, fix(L/2)+1)*Fn; % Frequency Vector
Iv = 1:length(Fv); % Index Vector
figure(1)plot(Fv, abs(FTvr(Iv,1))*2, '-b')hold onplot(Fv, abs(FTvr(Iv,2))*2, '--r')plot(Fv, abs(FTvr(Iv,3))*2, ':g')hold offgridaxis([0 10 ylim])
Try this:
D = dlmread('voltage_u.txt','\t', 4, 0);D = D(1:end-1,1:2); % First Two Columns (Third is 0), Elkiminat (0.0) In Last Row
t = D(:,1); % Time
V = D(:,2); % Volts
L = size(D,1); % Signal Length
tv = linspace(min(t), max(t), L); % Create Regularly-Spaced Time Vector
Ts = tv(2)-tv(1); % Sampling Interval
Fs = 1/Ts; % Sampling Frequency
Vv = resample(V, t, Fs); % Resample To Constant Sampling Rate
Fn = Fs/2; % Nyquist Frequency
FVv = fft(Vv)/L; % Discrete Fourier Transform
Fv = linspace(0, 1, fix(L/2)+1)*Fn; % Frequency Vector
Iv = 1:numel(Fv); % Index Vector
figuresemilogy(Fv, abs(FVv(Iv))*2)gridxlabel('Frequency (Hz)')ylabel('Amplitude (V)')
Your time-domain data are not regularly-sampled, so it is necessary to use the resample function to provide a uniformly-sampled vector in order for the fft function to produce the correct results.
Explore this at your leisure to understand how it works.
Best Answer