?? autocorr.m
字號:
%genertate the autocorrelation with two approaches..
%Programmed by Benjamin.Frank, 19-Feb-2009
function y = autocorr(x)
x = randn(1,20);
%the first method
N = length(x);
M = 10;
Rx = zeros(1,M+1);
for m=1:M+1,
for n=1:N-M+1
Rx(m) = Rx(m)+x(n)*x(n+m-1);
Rx(m) = Rx(m)/(N-m+1);
end
end
%the second method..
N=length(x);
L=M+1;
x1=zeros(N+L-1,1);
x2=x1;
x=x-mean(x);
x1(1:N,1)=x;
for k=1:L
x2=zeros(N+L-1,1);
x2(k:N+k-1,1)=x;
r(k)=x1'*x2;
end
r=r/N;
if 1,
stem(Rx);
hold on
stem(r);
end
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -