calculating auto-correlation function of a matrix

Hi, How can I calculate autocorrelation of a complex matrix ? (applied on the first dimension) As far as I know xcorr() is only for vectors.
Thanks

 Accepted Answer

Do you mean you want to compute autocorrelation for each column? If so, you can always use a for loop to do that, e.g.,
x = ones(10,2);
r = zeros(2*size(x,1)-1,size(x,2);
for m = 1:size(x,2)
r(:,m) = xcorr(x(:,m));
end
Or if you don't mind dealing with cell arrays, you can always do
x = ones(10,2);
r = arrayfun(@(n)xcorr(x(:,n),1:size(x,2),'UniformOutput',false);

5 Comments

Thanks Honglei for your answer. My matrix is: 17 x 300 , after autocorrelation I should have an output of 1 x 300. Because the matrix is complex, I am guessing it must be through conjugation and sum. But I don't know how to do it.
Can you help?
Thanks
It's not obvious to me what operation you want to do. There are many ways to output a 1x300 vector form a 17x300 matrix. Could you clarify how your correlation is defined?
Dear Honglei, the attached photo is the way that I should implement autocorrelation. So there are complex number multiplication (complex conjugate) and a sum. The output of this operation must give a (1 x 300) matrix in my case. Thanks
the short version of the above formula:
Based on that information, if I treat each column as a signal, I can have a 33x300 matrix, not a 1x300 matrix, unless we are talking about a specific time lag.

Sign in to comment.

More Answers (1)

There is an xcorr2() and normxcorr2() that can handle 2-D matrices like a 17 x 300 matrix. Not sure about complex numbers though - I've never tried it with those, just with real numbers. For what it's worth, I've attached a demo.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!