Getting a perfect ifft for an input time series

7 views (last 30 days)
Hi,
I have an input time series which needs to be converted to output time series by applying a transfer function. In order to do that, I need to do fft of my input time series, get its one sided amplitude spectrum, multiply the transfer function (frequency dependent) by it, and then get the one-sided output spectrum. Now the output spectrum needs to be converted to output time series using ifft function. However, the output I receive is not even close to what is expected.
I face two major issues:
(1) The ifft function is not doing inverse transform in the right manner. Somehow the conjugates and the complex number is making it weird
(2) Since the transfer function is multiplied by one-sided amplitude spectrum of the input, hence the output spectrum is also one-sided, which is making the output time series one-half of the length of input time series. How to resolve this?
Code:
X: input time series
L: Length of the time series
Fw: frequency dependent transfer function
One-sided spectrum is obtained using:
Y = fft(X);
P2 = abs(Y/L);
P1 = P2(1:L/2+1);
P1(2:end-1) = 2*P1(2:end-1);
f = Fs*(0:(L/2))/L;
plot(f,P1)
title('Single-Sided Amplitude Spectrum of X(t)')
xlabel('f (Hz)')
ylabel('|P1(f)|')
% Transfer function multiplication
Outputspectrum= Fw.* P1;
Outputseries=ifft(Outputspectrum);
Can any of us please suggest in this manner?

Answers (1)

Mathieu NOE
Mathieu NOE on 19 Nov 2021
hello
the output spectrum must be augmented from single sided to double sided fft (make a symetrical of it and concatenate both vectors)
example below (only the output spectrum here is not affected by a transfer function)
clc
clearvars
x = randn(100,1);
N = length(x);
time = (0:N-1);
Y = fft(x,N); % double sided fft vector
n2 = floor(N/2) + 1; % indices for one sided fft
h=Y(1:n2); % one sidded fft vector
h_flipped = h(n2-1:-1:2) % symetrical of one sidded fft vector
hh = [h ; conj(h_flipped)]; % concatenation of both vectors to re-create the double sided spectrum
acc_ifft1=ifft(Y,N); % works fine (reference)
acc_ifft2=ifft(hh,N); % works fine too
plot(time,x,'.-b',time,acc_ifft1,'dr',time,acc_ifft2,'*k');
  3 Comments

Sign in to comment.

Categories

Find more on Fourier Analysis and Filtering in Help Center and File Exchange

Tags

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!