Converting frequency domain to Time Domain using IFFT.
30 views (last 30 days)
Show older comments
Hello Experts,
I got a force data w.r.t frequency I want to convert it into force vs time. Can anyone please help with how to take sample rate, length and the plot with time of 0 to 10 secs
Thanks
5 Comments
Yashika Chauhan
on 4 Dec 2022
@Star Strider I also have same issue can you please help me with the code?
Answers (1)
Star Strider
on 5 Oct 2021
I made some assumptions and managed to invert the frequency-domain signal —
T1 = readtable('https://www.mathworks.com/matlabcentral/answers/uploaded_files/758601/Freq_to_timedomain.xlsx','VariableNamingRule','preserve')
% Check = [mean(diff(T1.Frequency)) std(diff(T1.Frequency))*1E15] % Check Frequency Spacing % Regularity
FT1 = T1.('Compressor Signal') .* exp(1j*deg2rad(T1.Phase)) % Complex Vector — Assumes Frequency In Hz & Phase In Degrees
FT1 = [0;FT1]; % Create % Concatenate DC Component
Fn = T1.Frequency(end); % Nyquist Frequency (Hz Assumed)
Fs = 2*Fn; % Sampling Frequency (Hz Assumed)
Ts = 1/Fs; % Sampling Interval (Sampling Period) (Seconds Assumed)
FT2 = [FT1; flip(conj(FT1))]; % Concatenate Flipped Complex Conjugate To End
Time = linspace(0, 1, numel(FT2))*Ts; % Create Time Vector (Assumes Highest Frequency Is The Nyquist Frequency)
IFT2 = ifft(FT2)
figure
yyaxis left
plot(T1.Frequency, T1.('Compressor Signal'))
ylabel('Amplitude')
yyaxis right
plot(T1.Frequency, T1.Phase)
ylabel('Phase (°)')
grid
title('Original One-Sided Fourier Transform')
figure
yyaxis left
plot(Time, real(IFT2))
ylabel('Real Component')
yyaxis right
plot(Time, imag(IFT2))
ylabel('Imaginary Componnent')
grid
title('Time-Domain Reconstruction')
xlim([min(Time) max(Time)])
There is something wrong with either the original data, or my interpretation of it (most likely the units, and that the omitted DC component is 0) and that the highest frequency in the data is the Nyquist frequency, because the imaginary component of the ifft should be essentially zero. (If the DC component is not 0, correct that in the ‘FT1’ creation assignment.)
I am confident that the code is correct, so it may be necessary to experiment with the unit conversions (if necessary) to produce a time-domain result with an essentially zero imaginary component. I have no idea what the original time-domain data look like, so I have nothing to compare it to.
.
0 Comments
See Also
Categories
Find more on Spectral Measurements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!