且构网

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

Matlab互相关与相关系数问题

更新时间:2023-02-26 19:01:54

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

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).