matlab中自相关函数xcorr

发布时间:2024-06-02 00:51 发布:上海旅游网

问题描述:

1、介绍一下MATLAB函数xcorr的使用
2、自相关是什么意思
3、两个数相关为什么是两个数的乘积
xcorr(2,2)=4 %???

给几个简单例子讲解一下

在线等

问题解答:

自相关函数是描述随机信号X(t)在任意两个不同时刻t1,t2的取值之间的相关程度.设原函数是f(t),则自相关函数定义为R(u)=f(t)*f(-t),其中*表示卷积.

给个例子:
dt=.1;
t=[0:dt:100];
x=cos(t);
[a,b]=xcorr(x,'unbiased');
plot(b*dt,a)
上面代码是求自相关函数并作图,

matlab中查看帮助时,
help xcorr 解释其意思是:
C(m) = E[A(n+m)*conj(B(n))] = E[A(n)*conj(B(n-m))];

但是,在调用xcorr函数求自相关时,有 scaleopt参数
r=xcorr(s,SCALEOPT)

SCALEOPT有
'biased' - scales the raw cross-correlation by 1/M.
'unbiased' - scales the raw correlation by 1/(M-abs(lags)).
'coeff' - normalizes the sequence so that the auto-correlations
at zero lag are identically 1.0.
'none' - no scaling (this is the default).

注意观察下面的测试:
s = [1 2 3]
r = xcorr(s);
r =
3.0000 8.0000 14.0000 8.0000 3.0000

当用r=xcorr(s,'unbiased')时就能得到
r =3.0000 4.0000 4.6667 4.0000 3.0000

热点新闻