I am using xcorr2(A,A) for computing the auto-correlation. But, the output is bigger than A. How I should trim the output to find the correct auto-correlation matrix? For example, my A matrix is 51×51 and the output will be 101×101. It is clear that the central point has the maximum correlation with itself which in this case is located in (26,26), but in the new auto-correlation map, it is located in (51,51). I need a general way to trim the final output.
I am using xcorr2(A,A) for computing the auto-correlation. But, the output is bigger than
Share
In general you have to take M points from M/2 to 3M/2 in the 1st dimension, and N points from N/2 to 3N/2 in the 2nd dimension, assuming A is an M-by-N matrix:
Here
Cwould be the trimmed output.EDIT:
For any two matrices
AandB, the result ofxcorr2(A, B)would be a (MA+MB-1)×(NA+NB-1) matrix. Here, however, you’ll have to decide for yourself which part you want to extract, if the matrices are not of equal dimensions. If you want to extract the significant central part, you can do it like so: