Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unsigned int valueIndex = 0; //**the size of the array value[]
- unsigned int n;//For fft
- unsigned int k;//For fft
- //Set sum for fft
- double sumReal=0;
- double sumImag=0;
- double powSumReal;
- double powSumImag;
- double powSum;
- float e; //value inside sin and cos when computing fft
- const float pi = 3.14159; //Create pi constant
- #define DELTA_SAMPLE_SIZE 125
- double value[DELTA_SAMPLE_SIZE];
- double z[DELTA_SAMPLE_SIZE];
- for(n=0; n<valueIndex; n++){
- for(k=0; k<valueIndex; k++){
- e = -2.0*(pi/((float)valueIndex+1))*((float)n+1.0)*((float)k+1.0);
- sumReal = sumReal + value[k]*cos(e);
- sumImag = sumImag + value[k]*sin(e);
- }
- powSumReal = pow((float)sumReal,2.0);
- powSumImag = pow((float)sumImag,2.0);
- powSum = powSumReal+powSumImag;
- z[n] = sqrt((float)powSum);
- sumReal = 0; //Reset
- sumImag = 0; //Reset
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement