NCC_ML
NCC_ML

Reputation: 1

Obtaining IFFT from frequency domain analytic formula

I'm trying to obtain the time domain signal from an analytic formula in frequency domain, specifically, the formula is:

Formula implemented

The problem arises when implementing an IFFT, since the following impulse response is obtained:

Impulse response

It is clear that the first part seems to be ok, however, there is a high level of noise and an increasing 'slope' as the signal comes to an end.

Now, when starting in frequency domain, I'm defining a frequency vector, with frequency resolution based on the size of the FFT.

%% Sampling Frequency + Size FFt

Fs = 512; %Sampling Frequency
Nfft = 2^12; %FFT Size
df = Fs/Nfft; %Frequency Resolution
f = 0:df:180; %Frequency Vector

Then the formula is applied and a frequency vector is obtained. Later an IFFT of size NFFT is applied:

%%Obtain impulse response
x = ifft(P_w,Nfft); %P_w is obtained by formula (1)
t = (0:(length(x)-1))/Fs; %Time Vector

As soon as I plot the real part of x, the result obtained in image 2 is seen. Is there any advice on how to overcome this? I mean, I shouldn't be getting that last 'noisy' portion of the signal or am I omitting an error in the code?

EDIT:

I've made a mistake in the frequency vector, actually, it starts from 0:

f = 0:df:180; %Frequency Vector

Upvotes: 0

Views: 438

Answers (2)

user28665430
user28665430

Reputation: 1

i have encountered a very similar issue. First of all, do what everyone suggested and zero pad the vector to go incrementally down to 0 and create a conjugate symmetric mirror image at the end of the vector before applying ifft. this is just the proper way to do it.

but the problem still remains, right?

Well what i found is that zero padding somehow causes this. im really not sure why and it might be hidden behind matlabs algorithm implementing the operation.

you can solve it though.

what you want to do is first to smooth out the transition, instead of having a sudden jump to zero

Upvotes: 0

KKS
KKS

Reputation: 1389

In my guess, you missed zero-pad on low frequency range under 5Hz, if your P_w is started from 5Hz.

Supposing my guess is right, plz, put 40 zeros in front of P_w before ifft.

40 zeros correspond to 0Hz~4.875Hz range, since df=0.125.

If P_w is column vector : P_w=[zeros(40,1);P_w];

If P_w is row vector : P_w=[zeros(1,40) P_w];

Upvotes: 0

Related Questions