Converting frequency domain to Time Domain using IFFT.

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

That depends on what the data are. If you have the amplitude and phase data, or the complex Fourier transform, and the lowest frequency is 0 Hz and the highest frequency is the Nyquist frequency, inverting it, even if you only have half of it, is straightforward. If you only have the amplitude or power, then inverting it is not possible.
Hi, thanks for your time.PFA of excel which contains forces vs fre data.
This dataI want to convert it into time domain. Can you please help. I am very new to this
Unfortunately, I cannot help. The data contain only frequency and magnitude, so it cannot be inverted.
T1 = readtable('https://www.mathworks.com/matlabcentral/answers/uploaded_files/755579/Force_Freq.xlsx', 'VariableNamingRule','preserve')
T1 = 60×2 table
Frequency Force Signal _________ ____________ 39 151.21 78.22 16.765 117.44 15.478 156.66 15.68 195.88 12.711 235.1 17.673 274.32 13.923 313.54 14.618 352.76 31.821 391.98 12.614 431.2 13.436 470.42 11.195 509.64 14.014 548.86 15.86 588.08 13.473 627.3 14.609
figure
plot(T1.Frequency, T1.('Force Signal'))
grid
.
Now I got magnitude and phase data w.r.t frequency. Can you please help me with the code.

Sign in to comment.

Answers (1)

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')
T1 = 51×3 table
Frequency Compressor Signal Phase _________ _________________ ________ 39 0.44633 2.1385 78.22 0.22602 1.0094 117.44 0.0073646 -0.11463 156.66 0.010899 1.4285 195.88 0.0023688 1.1573 235.1 0.0063101 0.60217 274.32 0.0082103 0.948 313.54 0.010135 0.1509 352.76 0.0026814 1.9953 391.98 0.0021176 -2.2674 431.2 0.0012498 0.021459 470.42 0.00044738 -1.8534 509.64 0.00037295 -1.6413 548.86 0.00064796 1.326 588.08 0.00067373 2.2295 627.3 0.00083095 0.72299
% Check = [mean(diff(T1.Frequency)) std(diff(T1.Frequency))*1E15] % Check Frequency Spacing % Regularity
Check = 1×2
39.2200 59.1180
FT1 = T1.('Compressor Signal') .* exp(1j*deg2rad(T1.Phase)) % Complex Vector — Assumes Frequency In Hz & Phase In Degrees
FT1 =
0.4460 + 0.0167i 0.2260 + 0.0040i 0.0074 - 0.0000i 0.0109 + 0.0003i 0.0024 + 0.0000i 0.0063 + 0.0001i 0.0082 + 0.0001i 0.0101 + 0.0000i 0.0027 + 0.0001i 0.0021 - 0.0001i 0.0012 + 0.0000i 0.0004 - 0.0000i 0.0004 - 0.0000i 0.0006 + 0.0000i 0.0007 + 0.0000i 0.0008 + 0.0000i 0.0021 + 0.0001i 0.0006 - 0.0000i 0.0111 + 0.0003i 0.0054 - 0.0001i 0.0013 + 0.0001i 0.0010 - 0.0000i 0.0014 + 0.0000i 0.0016 - 0.0000i 0.0025 - 0.0000i 0.0006 + 0.0000i 0.0019 - 0.0000i 0.0016 + 0.0001i 0.0014 + 0.0000i 0.0022 - 0.0000i 0.0016 + 0.0000i 0.0008 - 0.0000i 0.0015 + 0.0001i 0.0054 + 0.0001i 0.0017 + 0.0001i 0.0032 + 0.0000i 0.0156 - 0.0002i 0.0092 + 0.0001i 0.0045 - 0.0001i 0.0039 - 0.0000i 0.0051 - 0.0001i 0.0032 + 0.0001i 0.0021 + 0.0001i 0.0037 + 0.0000i 0.0036 - 0.0000i 0.0044 + 0.0001i 0.0019 + 0.0001i 0.0030 + 0.0001i 0.0014 - 0.0000i 0.0014 + 0.0000i 0.0001 + 0.0000i
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)
IFT2 =
0.0161 - 0.0000i 0.0128 - 0.0004i 0.0128 - 0.0008i 0.0125 - 0.0011i 0.0108 - 0.0013i 0.0109 - 0.0017i 0.0093 - 0.0017i 0.0076 - 0.0016i 0.0069 - 0.0017i 0.0058 - 0.0016i 0.0046 - 0.0014i 0.0042 - 0.0015i 0.0021 - 0.0008i 0.0010 - 0.0004i -0.0000 + 0.0000i -0.0014 + 0.0007i -0.0021 + 0.0011i -0.0033 + 0.0019i -0.0046 + 0.0028i -0.0050 + 0.0033i -0.0055 + 0.0038i -0.0059 + 0.0043i -0.0061 + 0.0048i -0.0067 + 0.0056i -0.0067 + 0.0059i -0.0062 + 0.0059i -0.0065 + 0.0065i -0.0060 + 0.0064i -0.0059 + 0.0067i -0.0060 + 0.0072i -0.0052 + 0.0066i -0.0049 + 0.0066i -0.0045 + 0.0066i -0.0039 + 0.0060i -0.0037 + 0.0061i -0.0032 + 0.0057i -0.0025 + 0.0047i -0.0022 + 0.0044i -0.0018 + 0.0040i -0.0015 + 0.0036i -0.0013 + 0.0033i -0.0009 + 0.0026i -0.0006 + 0.0020i -0.0005 + 0.0018i -0.0004 + 0.0015i -0.0002 + 0.0010i -0.0002 + 0.0010i -0.0000 + 0.0002i -0.0000 + 0.0001i 0.0000 - 0.0000i 0.0000 - 0.0000i 0.0000 - 0.0000i 0.0000 - 0.0002i -0.0000 - 0.0005i -0.0000 - 0.0004i -0.0000 - 0.0004i -0.0001 - 0.0006i -0.0001 - 0.0007i -0.0003 - 0.0014i -0.0003 - 0.0015i -0.0005 - 0.0019i -0.0006 - 0.0022i -0.0007 - 0.0024i -0.0010 - 0.0030i -0.0014 - 0.0037i -0.0016 - 0.0039i -0.0019 - 0.0043i -0.0023 - 0.0047i -0.0026 - 0.0049i -0.0033 - 0.0058i -0.0037 - 0.0062i -0.0039 - 0.0060i -0.0045 - 0.0066i -0.0048 - 0.0066i -0.0051 - 0.0065i -0.0059 - 0.0070i -0.0058 - 0.0065i -0.0058 - 0.0061i -0.0062 - 0.0062i -0.0059 - 0.0056i -0.0063 - 0.0056i -0.0063 - 0.0053i -0.0056 - 0.0044i -0.0054 - 0.0040i -0.0050 - 0.0035i -0.0045 - 0.0029i -0.0040 - 0.0024i -0.0027 - 0.0015i -0.0014 - 0.0008i -0.0007 - 0.0003i 0.0007 + 0.0003i 0.0016 + 0.0007i 0.0028 + 0.0011i 0.0048 + 0.0017i 0.0053 + 0.0016i 0.0064 + 0.0018i 0.0075 + 0.0018i 0.0082 + 0.0018i 0.0098 + 0.0018i 0.0113 + 0.0017i 0.0111 + 0.0013i 0.0128 + 0.0012i 0.0130 + 0.0008i 0.0129 + 0.0004i
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.
.

Products

Release

R2019b

Asked:

on 1 Oct 2021

Commented:

on 4 Dec 2022

Community Treasure Hunt

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

Start Hunting!