four1


elaatsch
04-24-2003, 06:17 AM
:confused: Hi !
Is implemented the four1 function into my app and generated a sine wave. I displayed the wave in a graphical user interface for displaying measurement data.
I filled my complex array with the real component set to the curve value and the imag component set to zero.
Then I used four1 to render the fft.
As an output I get a curve that is a constant function except for the first value ! what went wrong ?
I expected the output to be three spikes !

What went wrong ! Please help !

void CFftDlg::OnButton1() //button pressed
{
CNiReal32Vector v1; //just an array
int iSize=512;
v1.SetSize(iSize);

double dblInc=2*PI/(double)iSize;
float *dblaFFT=new float[iSize*2];


for(int i=0;i<iSize;i++) //generate input
{
v1[i]=sin(dblInc*i);
dblaFFT[i*2]=v1[i];
dblaFFT[i*2+1]=0;

}
m_cwgGraph1.GetPlots().Item(1).PlotY(v1);
four1(dblaFFT,iSize,0);
for( i=0;i<iSize;i++)
{
double real=dblaFFT[i*2];
double img=dblaFFT[i*2+1];

double ampl=sqrt(real*real+img*img);
double phase=atan(img/real);
v1[i]=ampl; //parse to array

}
//display array
m_cwgGraph2.GetPlots().Item(1).PlotY(v1);
}