自相關函式是描述隨機訊號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
自相關函式是描述隨機訊號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