Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.



frequency to time domain using IFFT and FFT for a realvalued function
Posted:
Nov 24, 2012 4:03 PM


Hi, I have a realvalued function in frequency domain and I'm trying to IFFT to get the signal in time domain and then FFT back to frequency domain. However, I'm unable to get back the original signal. The first step IFFT gives me the correct function but FFT'ing it does not give the original signal. Any ideas what I'm doing wrong? here's my code:
fsam=10:0.1:10; % frequency vector test_func=exp(fsam.^2); % testfunction
fsamp=fsam(1)fsam(2); % \Delta_frequency nfft=2^12; r0=length(test_func); dt=1/fsamp;
x = ifft(ifftshift(test_func),nfft); % DFT of signal g = (nfft/2:nfft/21)*(1/(fsamp*nfft)); % Time range q = ifftshift(x);
dg=g(1)g(2); y = fft(fftshift((q)),nfft); w = (nfft/2:nfft/21)*(2*dg); %Frequency range; also tried "fsamp" instead of "2*dg" s = fftshift(y);
figure subplot(2,1,1) plot(fsam,testfunc) %original signal hold on plot(w,real(s),'r') %signal after IFFT and FFT hold off
subplot(2,1,2) plot(g,real(q)) %real part of the signal after IFFT hold on plot(g,imag(q),'r') %imaginary part of the signal after IFFT hold off



