简体   繁体   中英

complex conjugate transpose matlab to C

I am trying to convert the following matlab code to c

cX = (fft(inData, fftSize) / fftSize);
Power_X = (cX*cX')/50;

Questions:

  1. why divide the results of fft (array of fftSize complex elements) by fftSize?
  2. I'm not sure at all how to convert the complex conjugate transform to c, I just don't understand what that line does.

Peter

1. Why divide the results of fft (array of fftSize complex elements) by fftSize?

Because the "energy" (sum of squares) of the resultant fft grows as the number of points in the fft grows. Dividing by the number of points "N" normalizes it so that the sum of squares of the fft is equal to the sum of squares of the original signal.

2. I'm not sure at all how to convert the complex conjugate transform to c, I just don't understand what that line does.

That is what is actually calculating the sum of the squares. It is easy to verify cX*cX' = sum(abs(cX)^2), where cX' is the conjugate transpose.

  1. Ideally a Discrete Fourier Transform (DFT) is purely a rotation, in that it returns the same vector in a different coordinate system (ie, it describes the same signal in terms of frequencies instead of in terms of sound volumes at sampling times). However, the way the DFT is usually implemented as a Fast Fourier Transform (FFT), the values are added together in various ways that require multiplying by 1/N to keep the scale unchanged.

    Often, these multiplications are omitted from the FFT to save computing time and because many applications are unconcerned with scale changes. The resulting FFT data still contains the desired data and relationships regardless of scale, so omitting the multiplications does not cause any problems. Additionally, the correcting multiplications can sometimes be combined with other operations in an application, so there is no point in performing them separately. (Eg, if an application performs an FFT, does some manipulations, and performs an inverse FFT, then the combined multiplications can be performed once during the process instead of once in the FFT and once in the inverse FFT.)

  2. I am not familiar with Matlab syntax, but, if Stuart's answer is correct that cX*cX' is computing the sum of the squares of the magnitudes of the values in the array, then I do not see the point of performing the FFT. You should be able to calculate the total energy in the same way directly from iData ; the transform is just a coordinate transform that does not change energy, except for the scaling described above.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM