0001 function [C,tw,m]=nt_cov_lags(x,y,shifts)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018 if nargin<2; error('!'); end
0019 if nargin<3 || isempty(shifts); shifts=[0]; end
0020
0021 if isnumeric(x)
0022
0023 if size(y,1)~=size(x,1); error('!'); end
0024 if size(y,3)~=size(x,3); error('!'); end
0025 n=size(x,2)+size(y,2);
0026 C=zeros(n,n,length(shifts));
0027 for iPage=size(x,3)
0028 for iLag=1:length(shifts)
0029 [xx,yy]=nt_relshift(x,y,shifts(iLag));
0030 C(:,:,iLag)=C(:,:,iLag) +[xx,yy]'*[xx,yy];
0031 end
0032 end
0033 m=size(x,2);
0034 tw=size(x,1)*size(x,3);
0035 else
0036
0037 n=size(x{1},2)+size(y{1},2);
0038 C=zeros(n,n,length(shifts));
0039 tw=0;
0040 for iCell=1:length(x);
0041
0042 C=C+nt_cov_lags(x{iCell},y{iCell},shifts);
0043 tw=tw+size(x{iCell},1);
0044 end
0045 m=size(x{1},2);
0046 end
0047