0
votes

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
1
Shouldn't P_w be a vector of complex amplitudes instead of frequencies? How do you build Pn before applying the formula? For now it's quite hard to answer as this isn't a minimal reproducible exampleBillBokeey
In fact it is. I meant that P_w is the frequency domain signal obtained using the first formula. That is the signal that needs to be transformed into time domain, yielding an impulse response.NCC_ML
Right, I'd suggest you change "frequency vector" to "frequency domain vector" in your question to avoid misunderstanding. Now how do you build Pn before applying your formula? This is crucial..BillBokeey
For example, P_w should be a vector whose first value is real and representing the average of your time domain signal, while the rest should be of the form [P1 P2 .... Pm 'Optionnal Nyquist term' conj(Pm) .... conj(P2) conj(P1)] in order for the IFFT to workBillBokeey
Also, the upper bound of your frequency vector f should depend on the FFt size, And it should've negative values (see previous comment)BillBokeey

1 Answers

0
votes

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];