Matlab Cross correlation vs Correlation Coefficient question

前端 未结 3 480
清歌不尽
清歌不尽 2021-01-16 03:10

I\'m writing a program in C++ but using data from matlab involving Cross Correlation. I understand that when I do a correlation on 2 sets of data it gives me a single correl

3条回答
  •  遥遥无期
    2021-01-16 03:41

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

提交回复
热议问题