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

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

问题描述

我正在用C ++编写程序,但使用的是来自matlab的涉及互相关的数据. 我了解到,当我对2组数据进行关联时,它会给我一个相关系数数字,指示它们是否相关.但是我想对数据系列使用互相关.当我在Matlab上运行交叉相关"时,它给了我很多数据,并且当绘制该图时,它看起来像一个三角形...我知道相关"应该在+/- 1之间,但是朝向三角形尖端的数据却没有.不能同时上升等.例如,我是否对交叉相关性给我感到困惑,还是交叉相关性给我的数据实际上是每个点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')时, 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).

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

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