STM32,使用了FFT变换,我看到网上说输出的数组,求虚部比实部的反正切就是信号的相位,但是得到的明显不是啊
void GetPowerMag()
{
signed short lX,lY;
float X,Y,Mag;
unsigned short i;
for(i=0; i<NPT/2; i++)
{
lX = (OutBufArray[ i] << 16) >> 16; //虚部
lY = (OutBufArray[ i] >> 16); //实部
chucun[ i] = InBufArray[ i];
imag[ i] = lX;
real[ i] = lY;
//除以32768再乘65536是为了符合浮点数计算规律
X = NPT * ((float)lX) / 32768;
Y = NPT * ((float)lY) / 32768;
Mag = sqrt(X * X + Y * Y) / NPT;
if(i == 0)
MagBufArray[ i] = (unsigned long)(Mag * 32768);
else
MagBufArray[ i] = (unsigned long)(Mag * 65536);
}
}
具体求出来的反正切值用不用再进行转换得到相位,还是说我的过程就是错的? |