How to convert complex one sided spectrum into time domain
45 views (last 30 days)
Show older comments
Csanad Levente Balogh
on 18 Mar 2021
Commented: Bjorn Gustavsson
on 18 Mar 2021
Hi!
I have a one sided spectrum with complex values.I want to convert in back to time domain. As I se, the matlab ifft function converts two sided spectrum into time domain. My qustion is, is there a matlab function that can apply invers fourier transform on one sided spectrum? If there isn't how can I conert a complex one soided spectrum to two sided?
0 Comments
Accepted Answer
Bjorn Gustavsson
on 18 Mar 2021
You can do something like this:
function fft4real = symmetrize(fftOnesided)
fft4real = [fftOnesided,0, fliplr(conj(fftOnesided(:,2:end)))];
end
If you try this on something like this:
t = 0:127;
I = sin(2*pi/128*3*t) + 0.4*sin(2*pi/128*7.2*t) + randn(size(t))/17;
fI = fft(I);
ssfI = fI(1:end/2);
tsfI = symmetrize(ssfI);
clf
plot(t,I)
hold on
plot(t,ifft(tsfI))
You'll see that you have an almost perfect fit, there is a missing sample at the Nyquist-frequency but that's unavoidable, I think. This obviously assumes that your original signal is real-valued...
HTH
2 Comments
Bjorn Gustavsson
on 18 Mar 2021
Ah, I forgot that one should take into account the amplitude of the negative frequency-coefficients when converting to the single sided spectrum. That is all, then for that case one should correspondingly divide all non-DC components with 2 to correct for that, when converting the single-sided spectrum to a 2-sided.
More Answers (1)
Walter Roberson
on 18 Mar 2021
You specifically mention "complex one sided". Is the implication that the frequency data you have is complex valued but the time domain data is intended to be real-valued? If so then that can be handled without much difficulty. However if the time-domain data is intended to be complex-valued then you do not have enough information to reconstruct it.
Assuming that it is the positive frequencies in the data, and that the first entry in the data is the "0" frequency, then
%build some demonstration data
N = 127;
F0 = 10; %total signal, mean times signal length
F1 = [F0, complex(randn(1,N),randn(1,N)).*exp(-(1:N)./N)];
%F1 is the demonstration one-sided complex frequency-domain signal.
plot(abs(F1)); title('one-sided frequency')
%reconstruct
F2 = [F1, fliplr(conj(F1(2:end)))];
%F2 is the reconstructed two-side complex frequency-domain signal
plot(abs(F2)); title('two-sided reconstructed frequency')
%ifft
td = ifft(F2);
whos td
plot(td); title('time domain')
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!