Getting back to time domain ifft
Afficher commentaires plus anciens
I am trying to filter random data in the frequency domain, and then converting the data back to the time domain, however when I use the following code, I am getting the output of ifft still as imaginary numbers. Any insight would be greatly appreciated.
srate=500;
time=500;
numdatapoints=srate*time;
x=rand(1,numdatapoints);
avgx=mean(x);
x=x-avgx;
Y=fft(x);
fftphase=angle(Y);
fftmag=abs(Y);
k=linspace(1, 250, numdatapoints);
j=1./k;
%filter to follow 1/f
for i=1:length(Y)
fftmag(i)=fftmag(i)*j(i);
end
z=fftmag.*exp(1i.*(fftphase));
y=ifft(z);
Réponses (1)
Wayne King
le 8 Mar 2013
Modifié(e) : Wayne King
le 8 Mar 2013
The problem is you are violating the conjugate symmetry property of a real-valued signal.
You are scaling the magnitude of the Fourier coefficient at K and N-K+2 differently. Those coefficients should just be complex conjugates of each other which means they should NOT differ in magnitude.
Like this:
x = randn(8,1);
xdft = fft(x);
xdft(2)
xdft(8-2+2)
So if you want to scale by 1/K you have to scale both K and N-K+2 by 1/K and not the latter by 1/(N-K+2)
1 commentaire
Catégories
En savoir plus sur Geometric Distribution dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!