How to convert complex one sided spectrum into time domain

41 visualizzazioni (ultimi 30 giorni)
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?

Risposta accettata

Bjorn Gustavsson
Bjorn Gustavsson il 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 Commenti
Csanad Levente Balogh
Csanad Levente Balogh il 18 Mar 2021
Thank you! This looks good. I noticed you only use the following code for the transformation to single sided spectrum:
ssfI = fI(1:end/2);
What if the spectrum was calculated from operations with other spectrums and the single sided transformation of those spectrums is done as shown in the eaxmples of fft?
FI = fft(I);
P2 = FI/L;
P1 = P2(1:L/2+1);
P1(2:end-1) = 2*P1(2:end-1);
Bjorn Gustavsson
Bjorn Gustavsson il 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.

Accedi per commentare.

Più risposte (1)

Walter Roberson
Walter Roberson il 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
Name Size Bytes Class Attributes td 1x255 2040 double
plot(td); title('time domain')

Prodotti


Release

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by