Frequency domain to Time domain

Hi,
I have experimental data of a signal in terms of frequency and acceleration. I want to convert this signal as a function of time using an inverse Fourier transform (ifft). What script could I use to the ifft? Is my approach correct? or should I have to use any thing about sampling frequency in my code? (if so, please help). The frequencies evenly spaced from 0 to 1024 at an interval of 0.5 Hz?
acceleration = xlsread('data','Sheet1','B3:B2051');
frequency = xlsread('data','Sheet1','A3:A2051');
time = ifft(frequency);
abs_time = abs(time);
subplot(2,1,1), plot(frequency,acceleration)
subplot(2,1,2), plot(abs_time,rms)
Thanks. It would be a huge help, I have no knowledge of signal processing concepts.

2 Comments

Hi John,
After running the code in the qeustion, can you post the results from the following commands:
[frequency(1:5) frequency(end)]
numel(frequency)
I'm asking because the question doesn't seem to line up with plots in the Answer below.
Error using horzcat
Dimensions of arrays being concatenated are not consistent.
Error in Autopowerat0percentpedal (line 7)
[frequency(1:5) frequency(end)]
where as for numel(frequency)
ans =
2049
Brother Paul, as per discussion in the other comment. Without phase data the inversion of Fourier transorm is not possible. Please refer that discussion for the correct approach. :)

Sign in to comment.

 Accepted Answer

Star Strider
Star Strider on 4 May 2022
The acceleration data must be complex, or the data must consist of an acceleration magnitude and an acceleration phase. The highest frequency should be the Nyquist frequency, or at least the sampling frequency of the original signal must be known.
Assuming that the acceleration magnitude and phase signals both exist, the frequency spacing is regular, and the highest frequency is the Nyquist frequency, the inversion would go something like this —
First, create a complex variable from the magnitude and phase vectors if it is not already complex:
accelz = mag .* exp(1j*phase) % The 'phase' Value Is The Unwrapped Phase In Radians
and the full acceleration signal becomes:
accelz_full = [accelz flip(conj(accelz))]
The time vector is derived from the one-sided frequency vector ‘fv’ as:
tv = linspace(0, numel(accelz_full)-1, numel(accelz_full))/(2*max(fv))
Then take the ifft of ‘accelz_full’ to get the time domain signal:
accelt = ifft(accelz_full, 'symmetric')
The result of the ifft calculation should be real.
.

6 Comments

Thank you for such a clear explaination kind person.
As always, my pleasure!
I have used the above script and acquired the data in time domain. As I understand, now the X-axis is in 'bin' values. I have to get the signal in for 30 seconds. (i.e, the X-axis should be 0 s to 30 s). I have written the following code to achieve that (line 12 to line 17). Is it the right approach?
rms = xlsread('data','Sheet1','B3:B2051');
fv = xlsread('data','Sheet1','A3:A2051');
mag = abs(rms);
phase = angle(rms);
accelz = mag .* exp(1j*phase);
accelz_full = [accelz flip(conj(accelz))];
tv = linspace(0, numel(accelz_full)-1, numel(accelz_full))/(2*max(fv));
accelt = ifft(accelz_full, 'symmetric');
subplot(3,1,1), plot(accelt)
subplot(3,1,2), plot(abs(accelt))
y_axis = abs(accelt);
N = length(fv); %length of frequency vector
sampling_time = 30 %duration of experiment = 30s
bin_vals = [0 : N-1];
duration_axis = (bin_vals/N)*2*sampling_time;
N_2 = ceil(N/2);
subplot(3,1,3), plot(duration_axis(1:N_2), y_axis(1:N_2)), xlabel('Time(s)'),ylabel('Magnitude');
And in doing so, I am getting the figure as follows,
Thank You :)
I have no idea what ‘rms’ is.
If it is complex, there is no need to compute the amplitude and angle. If it is a one-sided Fourier transform, append the flipped conjugate of it to the original vector and do the inversion.
If it is not complex, and only the frequency and anplitude values are present (no phase angle informaiton), then inverting the Fourier transform is not possible, since half of the necessary information (to create the complex vector) is missing.
Yes, I agree. I was just reading upon the documentation provided by the software (I got the data from) in this regards and it was mentioned that the phase information has been removed and only the amplitude values are plotted with respect to frequency.
And that if phase information is needed, I have to take the spectral data which has phase data included. Thank you for the help.
The 'rms' that I mentioned in the code was the rms acceleration values of my data.
As always, my pleasure!
If you have the ‘rms’ data with the phase information, then the inversion is possible.

Sign in to comment.

More Answers (0)

Products

Release

R2020a

Community Treasure Hunt

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

Start Hunting!