Re: Problem with fft/ifft - the thing is complex though it shouldn't
- From: "Mike L" <leunm@xxxxxxxxxxx>
- Date: Mon, 12 Jun 2006 09:49:56 -0400
I did something similar a while back. What I can tell you is that
you need to be VERY careful when using fft/ifft this way as a filter.
You need to define your w correctly, understand the output of fft
(see help file on fft, fftshift; the comment by Jeroen is also very
valid), there is a 1/N scaling factor, etc...
I don't have the code with me, but what I suggest you do is to work
with Maple first (hopefully you have it), symbolically, with some
simple functions and compare it with your matlab code to see if you
got it right.
Mike
Jeroen wrote:
vector
j_hab wrote:
I have a problem with the ifft. I want to filter a a timethere
accerleration signal (not complex) in freq domain - filter it
and transfer it back to time domain.same
Considering the following code with acc_t as a time domain acc.
signal:
ft = fft (acc_t); % generating frequency domain
im = imag (ft);
re = real (ft);
ar = im./re; %phase angle
fta = abs (ft); amplitude spectrum
fta_w = fta.*w; % filtering with e.g. linear filter w with the
length of fta
re_w = cos (ar).* fta_w; %real part of filtered spectrum
im_w = sin (ar).* fta_w; % imaginary part of filtered specrtum
ft_w = complex (re_w, im_w); generating complex (filtered)
whycomplex,
% until here everything is clear
ift = ifft (ft_w); %jumpin to time domain again
%now my problem:
acc_t_w = ????????? the filtered time acceleration signal is
shall I use abs (ift or real(ift)for a correct presentation?
absanyhow is it comlex?????
%%%%%%%%%%%%%%%%%%
Now ift is a complex signal and I DON'T KNOW WHY!!!!
If I do not apply any filter w it doesn´t become complex.
Anyhow....can I use the real part real (ift) or absolute part
.(ift) to present the correct (wrt the amplitude) filtered timesignal
of the acceleration acc_t?
Any kind of objective answer would be of great help.
Hi,
I had just a quick look at this, but it seems strange to me why you
split your signals into an amplitude part, and calculate the
corresponding angles also. Why not just straightforward:
X_w = fft(x_t); % To frequency domain.
X_w = X_w.*H_w; % Apply filter.
x_t = ifft(X_w); % Back to time.
Your filter 'H_w' in the frequency domain must be chosen carefully.
Suppose you have an N-point fft and you want to apply a lowpass
filter.
Then you make a real-valued lowpass filter 'H_w' first with N/2
points
from 0 Hz to fs/2. Then you make the full 'H_w' (assuming 'H_w' as
a
column vector):
H_w = [H_w ; 0 ; flipud(H_w(2:end))];
The reason for this construction is that the amplitude spectrum of
a
real signal is symmetrical around the single index (N/2 +1) (where
index
1 is DC). You may end up with very small imaginary parts in x_t due
to
calculation noise. Just take the real psrt of your result.
Jeroen
- References:
- Prev by Date: Re: little vectorization problem
- Next by Date: Re: little vectorization problem
- Previous by thread: Re: Problem with fft/ifft - the thing is complex though it shouldn't
- Next by thread: Re: Problem with fft/ifft - the thing is complex t
- Index(es):
Relevant Pages
|
Loading