question relating to FFT [message #65387] |
Mon, 02 March 2009 10:26  |
Hu
Messages: 35 Registered: January 2009
|
Member |
|
|
Hi, there
I try to use FFT function to smooth a curve (an array), and the code
is like this:
FUNCTION FOURIER,ARRAY ;*****FAST FOURIER FLITER
FILTER=1.0/(1.0+DIST(152)/4.0)^2
newARRAY=FFT(FFT(ARRAY,-1)*FILTER,1)
RETURN,newARRAY
END
when I got an array X (has 152 elements) and use this function like :
Y = FOURIER(X)
I got an result Y with 152 elements, but all the elements are complex
number, but How can I got an array filled with regular number, not
complex number?
I mean, I want to use the result to calculate regression relationship
with other array.
|
|
|
Re: question relating to FFT [message #65427 is a reply to message #65387] |
Wed, 04 March 2009 13:12  |
R.G. Stockwell
Messages: 363 Registered: July 1999
|
Senior Member |
|
|
"Hu" <jhaohu@gmail.com> wrote in message
news:65755654-c680-4de8-b611-6b75ace9fa75@n20g2000vba.google groups.com...
> Hi, there
> I try to use FFT function to smooth a curve (an array), and the code
> is like this:
>
>
> FUNCTION FOURIER,ARRAY ;*****FAST FOURIER FLITER
> FILTER=1.0/(1.0+DIST(152)/4.0)^2
> newARRAY=FFT(FFT(ARRAY,-1)*FILTER,1)
> RETURN,newARRAY
> END
>
> when I got an array X (has 152 elements) and use this function like :
>
> Y = FOURIER(X)
>
> I got an result Y with 152 elements, but all the elements are complex
> number, but How can I got an array filled with regular number, not
> complex number?
>
> I mean, I want to use the result to calculate regression relationship
> with other array.
There are many issues here.
Filter is 2D (152 by 152), array is 1D (152) and the function could have a
better name :)
First of all, FFTs are complex.
To filter a real valued signal in the fourier domain, you need to ensure
you filter is symmetric (and conjugate) about the origin. (where positive
frequencies come first, followed by the negative frequencies)
It seems that the above code approzimates that, although I don't
know if that is by design or by luck.
Then your result will be a complex variable, with all zeros (approx) in your
imaginary component.
You should check for that and flag an error if that is not true.
Lasly, DIST is a terrible filter. Even with the unusual use of IDL matrix
multiplication rules.
Check out the digitil_filter routines in IDL.
Cheers,
bob
|
|
|