Advertisement
Guest User

Untitled

a guest
Jun 17th, 2013
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. unsigned int valueIndex = 0; //**the size of the array value[]
  2. unsigned int n;//For fft
  3. unsigned int k;//For fft
  4. //Set sum for fft
  5. double sumReal=0;
  6. double sumImag=0;
  7. double powSumReal;
  8. double powSumImag;
  9. double powSum;
  10. float e; //value inside sin and cos when computing fft
  11. const float pi = 3.14159; //Create pi constant
  12.  
  13. #define DELTA_SAMPLE_SIZE 125
  14. double value[DELTA_SAMPLE_SIZE];
  15. double z[DELTA_SAMPLE_SIZE];
  16.  
  17. for(n=0; n<valueIndex; n++){
  18. for(k=0; k<valueIndex; k++){
  19. e = -2.0*(pi/((float)valueIndex+1))*((float)n+1.0)*((float)k+1.0);
  20. sumReal = sumReal + value[k]*cos(e);
  21. sumImag = sumImag + value[k]*sin(e);
  22. }
  23. powSumReal = pow((float)sumReal,2.0);
  24. powSumImag = pow((float)sumImag,2.0);
  25. powSum = powSumReal+powSumImag;
  26. z[n] = sqrt((float)powSum);
  27. sumReal = 0; //Reset
  28. sumImag = 0; //Reset
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement