且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Matlab 互相关 vs 相关系数问题

更新时间:2023-02-26 19:15:14

在 Matlab 中 xcorr(x,x) 给出信号 x 的自相关.它没有缩放,它只是信号与自身移位版本的内积向量.为了缩放它,使用 xcorr(x,x,'coeff').此命令将按信号的能量缩放您的自相关(换句话说,它将每个系数除以零滞后系数的值).请注意,当您进行互相关xcorr(x,y'coeff') 时,您将不会得到值 1和零延迟,因为缩放的执行方式不同.如果您将信号与其自身相关联,则它只会是 1(我希望支持数学公式,以便我可以为您写出来).

In Matlab xcorr(x,x) gives auto-correlation of signal x. It is not scaled, it's simply a vector of inner products of the signal with shifted versions of itself. In order to scale it, use xcorr(x,x,'coeff'). This command will scale your auto-correlation by signal's energy (in other words it will divide each coefficient by value of coefficient at zero lag). Note that when you're doing cross-correlation, xcorr(x,y'coeff'), you will not get a value of 1 and zero lag, because the scaling is performed differently. It will only be 1 if you're correlating a signal with itself (I wish SO supported math formulas so that I could write it out for you).