Matlab 互相关 vs 相关系数问题 [英] Matlab Cross correlation vs Correlation Coefficient question

查看:38
本文介绍了Matlab 互相关 vs 相关系数问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用 C++ 编写程序,但使用来自涉及互相关的 matlab 数据.我知道当我对 2 组数据进行相关时,它会给我一个单一的相关系数数字,表明它们是否相关.但我想对数据系列使用互相关.当我在 Matlab 上运行 Cross Correlation 时,它给了我很多数据,绘制时该图看起来像一个三角形......我知道 Correlation 应该在 +/- 1 之间,但三角形尖端的数据没有't 同时上升等等.我是否对互相关给我的东西感到困惑,或者互相关给我的数据实际上是每个点 s(t),p(t) 的相关系数?感谢您在澄清方面的任何帮助.

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 correlation coefficient number indicating if they are related. But I'm wanting to use Cross Correlation on the data series. When I run Cross Correlation on Matlab it gives me a lot of data and when plotted the plot looks like a triangle... I understand Correlation is supposed to be somewhere between +/- 1 but the data toward the tip of the triangle doesn't go up at the same time etc. Do I have a confusion with what Cross Correlation is giving me or is the data that Cross Correlation gives me actually correlation coefficients for each point s(t),p(t) for instance? Any help with clarifying is appreciated.

编辑 1(在 Phonon 的回应之后)

我的主要问题是:当我交叉关联 2 个数据系列时,我得到的数据是每个点的相关系数.例如,(0,10) 和 (0,8);我得到的数据是 x=0 处那 2 个图的相关系数吗?

My main question is: Is the data that I get when I cross correlate 2 data series the correlation coefficient for each point. For instance, (0,10) and (0,8); Is the data I'm getting the correlation coefficient of those 2 plots at x=0 ?

推荐答案

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

这篇关于Matlab 互相关 vs 相关系数问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆