From: Siyi Deng on
hi board:
Say I have a 60000 x 120 matrix A, I want to compute the cross-correlation sequences at a set of specific lags, for example lag [0 1 2 10 20 100 2000 30000];

from The XCORR function:
XCORR(A), when A is an M-by-N matrix, is a large matrix with
2*M-1 rows whose N^2 columns contain the cross-correlation
sequences for all combinations of the columns of A.
The zeroth lag of the output correlation is in the middle of the
sequence, at element or row M.

XCORR(...,MAXLAG) computes the (auto/cross) correlation over the
range of lags: -MAXLAG to MAXLAG, i.e., 2*MAXLAG+1 lags.
If missing, default is MAXLAG = M-1.

It seem that I have to create this 59999 x 14400 matrix first and extract my cross-correlations at these lags next. This is very inefficent;

On the other hand I can manually run for-loops and shift A and do A*A', but it can also be slow if I have very large amount of lags;

Could somebody please kindly point out a way to do this in spectral domain for specific lags? thanks!
From: Godzilla on
"Siyi Deng" <mr.siyi.deng(a)gmail.com> wrote in message <hssq1v$79$1(a)fred.mathworks.com>...
> hi board:
> Say I have a 60000 x 120 matrix A, I want to compute the cross-correlation sequences at a set of specific lags, for example lag [0 1 2 10 20 100 2000 30000];
>
> from The XCORR function:
> XCORR(A), when A is an M-by-N matrix, is a large matrix with
> 2*M-1 rows whose N^2 columns contain the cross-correlation
> sequences for all combinations of the columns of A.
> The zeroth lag of the output correlation is in the middle of the
> sequence, at element or row M.
>
> XCORR(...,MAXLAG) computes the (auto/cross) correlation over the
> range of lags: -MAXLAG to MAXLAG, i.e., 2*MAXLAG+1 lags.
> If missing, default is MAXLAG = M-1.
>
> It seem that I have to create this 59999 x 14400 matrix first and extract my cross-correlations at these lags next. This is very inefficent;
>
> On the other hand I can manually run for-loops and shift A and do A*A', but it can also be slow if I have very large amount of lags;
>
> Could somebody please kindly point out a way to do this in spectral domain for specific lags? thanks!

Look up the mathematical formula for cross correlation and you will find that it is just a multiplication (and division by other multiplications).

In your case, I would write the code to do the multiplies at a given lag.