Vectorizing Calculation of the Autocorreltion function of a Matrix (Per Column)

조회 수: 1 (최근 30일)
Hello.
I have a matrix
A = [1 2 3; 4 5 6; 7 8 9];
I want to calculate the Autocorrelation function of each of its columns.
Simple way to do so:
for ii = 1:size(A, 2)
autocorrelationFunction(:, ii) = conv2(A(:, ii), A(end:-1:1, ii));
end
Could anyone think of a vectorized way of doing so?
Thanks.

채택된 답변

Royi Avital
Royi Avital 2014년 9월 11일
It can be done using Toeplitz matrix.

추가 답변 (1개)

Daniel Shub
Daniel Shub 2011년 7월 27일
Wow, it is like a vectorization party in here today. Why do you want to vectorize your code? In recent years MATLAB has substantially sped up loops. If you are not using r2011a, you could speed up your loop by initializing autorcorrelationFunction to the correct size (r2011a has supposedly cut down on the cost of not pre-allocating arrays). You might be able to get a speed increase out of vectorization, but it may not be as big as you expect.
  댓글 수: 1
Royi Avital
Royi Avital 2011년 7월 27일
I know all / most the acceleration methods when dealing with loops.
I'm looking for something which removes the loop completely.
Thank you.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by