[comp.dsp] Check of an FFT routine...

jbs@en.ecn.purdue.edu (Spaggie) (04/04/91)

I have put together a program to do an FFT of any array of
data, but it doesn't seem to get the imag. part correct.
Can someone verify if this data is correct or not?

Data given to program, 32 data points..
---------------------------------------
-0.005093
-0.003797
-0.001432
0.004374
0.001606
0.000027
-0.004548
0.000919
0.005288
-0.004973
-0.001283
-0.001970
0.002802
0.007448
-0.000214
-0.006771
-0.004697
0.002116
0.003964
0.002788
-0.000533
-0.003011
-0.000788
0.000005
-0.000852
0.003107
-0.001298
-0.000009
0.001896
-0.002197
0.000841
-0.000112

	my fft routine then yeilds this..
Real, Imaginary
-------------------
-0.000200,-0.000000
-0.000201,-0.000001
-0.000212,0.000010
-0.000223,-0.000053
-0.000722,-0.000263
0.000427,0.000433
-0.001282,-0.000314
0.000184,0.001059
0.000162,0.000016
0.000187,0.000170
-0.000096,-0.000125
-0.000621,0.000399
0.000027,0.000028
0.000258,-0.000585
-0.000188,-0.000254
-0.000111,0.000147
 
	Can anyone verify this as being correct?

srf@claudius.juliet.ll.mit.edu ( Steve Feinstein) (04/04/91)

In article <1991Apr4.004750.15969@en.ecn.purdue.edu> jbs@en.ecn.purdue.edu (Spaggie) writes:
>   I have put together a program to do an FFT of any array of
>   data, but it doesn't seem to get the imag. part correct.
>   Can someone verify if this data is correct or not?
>
>
>                       my fft routine then yeilds th
>   Data given          Real, Imaginary              
>   -----------	        -------------------          
>   -0.005093	        -0.000200,-0.000000          
>   -0.003797	        -0.000201,-0.000001          
>   -0.001432	        -0.000212,0.000010           
>   0.004374	        -0.000223,-0.000053          
>   0.001606	        -0.000722,-0.000263          
>   0.000027	        0.000427,0.000433            
>   -0.004548	        -0.001282,-0.000314          
>   0.000919	        0.000184,0.001059            
>   0.005288	        0.000162,0.000016            
>   -0.004973	        0.000187,0.000170            
>   -0.001283	        -0.000096,-0.000125          
>   -0.001970	        -0.000621,0.000399           
>   0.002802	        0.000027,0.000028            
>   0.007448	        0.000258,-0.000585           
>   -0.000214	        -0.000188,-0.000254          
>   -0.006771	        -0.000111,0.000147           
>   -0.004697
>   0.002116
>   0.003964
>   0.002788
>   -0.000533
>   -0.003011
>   -0.000788
>   0.000005
>   -0.000852
>   0.003107
>   -0.001298
>   -0.000009
>   0.001896
>   -0.002197
>   0.000841
>   -0.000112
>	   Can anyone verify this as being correct?

Your values are wrong and there aren't enough of them, either.
You should be generating at least N FFT points for an N-point
array.  The example you've posted is a 16-pt FFT on 32-pt
data.  Here is what MATLAB generated:

  -0.0023  		-pi
  -0.0035 - 0.0047i
  -0.0060 + 0.0081i
   0.0083 + 0.0187i
   0.0009 - 0.0009i
  -0.0199 - 0.0128i
  -0.0031 + 0.0040i
   0.0060 - 0.0055i
   0.0052 - 0.0005i
   0.0059 - 0.0339i
  -0.0410 + 0.0101i
   0.0137 - 0.0138i
  -0.0231 + 0.0084i
  -0.0071 + 0.0017i
  -0.0068 - 0.0003i
  -0.0064 + 0.0000i
  -0.0064		0
  -0.0064 - 0.0000i
  -0.0068 + 0.0003i
  -0.0071 - 0.0017i
  -0.0231 - 0.0084i
   0.0137 + 0.0138i
  -0.0410 - 0.0101i
   0.0059 + 0.0339i
   0.0052 + 0.0005i
   0.0060 + 0.0055i
  -0.0031 - 0.0040i
  -0.0199 + 0.0128i
   0.0009 + 0.0009i
   0.0083 - 0.0187i
  -0.0060 - 0.0081i
  -0.0035 + 0.0047i	+pi


--

		Steve Feinstein

+-------------------------------------------------------------------------+
|  INTERNET:  srf@juliet.ll.mit.edu                                       |
|  USmail:    S. Feinstein, MIT Lincoln Lab, 29 Hartwell Ave.,            |
|             Lexington, MA 02173  USA                                    |
|  VOICE:     (617) 981-4017                                              |
+-------------------------------------------------------------------------+

dmassie@well.sf.ca.us (Dana C. Massie) (04/10/91)

In article <SRF.91Apr4100830@claudius.juliet.ll.mit.edu> srf@claudius.juliet.ll.mit.edu ( Steve Feinstein) writes:
>
>Your values are wrong and there aren't enough of them, either.
>You should be generating at least N FFT points for an N-point
>array.  The example you've posted is a 16-pt FFT on 32-pt
>data.  Here is what MATLAB generated:
>
>  -0.0023  		-pi
...
>		Steve Feinstein

I got the same results with matlab that Steve got.
When i wrote an FFT i found it *much* easier to use simple test signals
like a sine wave to test the fft.  I would strongly addvise
using a simple impulse in bin 0 of the input, then switch to an impulse in
bin 1, etc. and check the output of each case.  This is a very
effective method.  Also, once this is working, put an impulse in
bin 0 and bin 1 - this will test superposition.

good luck!

dmassie@well.sf.ca.us