From: Matt on
Hello,

I am having a bit of difficulty with the xcorr2 command, and getting the to locate my data in the correct place..

Currently, I have a large matrix (Dg) which was (4320 x 8640) of data. From it, I took a subset of data, from (1920:2161,5761) and called it GA. I know this data is exact, I have put them side by side, and truth checked them with '==' so their numbers are exact.

From there, I did

'g = xcorr2(Dg,GA);

%g = g/max(max(g));

[I,J]= find(g == max(g(:)))'

(the second line is % because I took it out to see if there was any difference, there was not)

The point I should get, I believe, is something along the lines of (2040,5761). However, the [I, J] I get back is (2854, 6929). I have flip flopped the GA and Dg in their position of of xcorr2, but the other way around produces data further off the mark.

I've tried my program there with smaller sets of data, like a 3x3 and a 2x1 matrix, but it still gives me not the correct points.

Any help would be great, thank you!