According to the documentation, there is no convenient 'same' option for the xcorr command like there is for conv to keep the output the same size as one of the inputs.
Is there a way to get around this problem besides calculating the appropriate indices and talking a subarray?
You’re right, there’s no such thing for
xcorr, and the problem is that even if you specifyMAXLAGyou will get a vector of length 2*MAXLAG+1, so it’s always going to be odd. If your input signal is odd, you can callxcorr( a,b, (length(a)-1)/2 );. If you’re delaing with even or arbitrary lengths, I’m afraid you’ll have to use subarray calculations.`However, to be clever you can use a similar trick, and simply say