?? vxcorr.m
字號:
%file vxcorr.m
function [c,lags]=vxcorr(a,b)
%this function calculates the unscaled cross_correlation of 2
%vectors of the same length . the output length(c) is
%length(a)+length(b)-1. It is a simplified function of xcorr
%function in matlabR12 using the definiton:
%c(m)=E[a(n+m)*conj(b(n))]=E[a(n)*conj(b(n-m))]
%
a=a(:); %convert a to column vextor
b=b(:); %convert b to column vector
M=length(a); %same as length(b)
maxlag=M-1; %maxium value of lag
lags=[-maxlag:maxlag]'; %maximum value of lag
A=fft(a,2^nextpow2(2*M-1)); %fft of A
B=fft(b,2^nextpow2(2*M-1)); %fft of B
c=ifft(A.*conj(B)); % cross correlation
%
%Move negative lags before positive lags
%
c=[c(end-maxlag+1:end,1);c(1:maxlag+1,1)];
%
%Return row vector if a,b are row vectors.
%
[nr nc]=size(a);
if(nr>nc)
c=c.';
lags=lags';
end
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -