⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vxcorr.m

📁 在这个例子中
💻 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 + -