Pregunta

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?

¿Fue útil?

Solución

You're right, there's no such thing for xcorr, and the problem is that even if you specify MAXLAG you 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 call xcorr( 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

R = xcorr( a,b, floor(length(a)/2) );
R = R( 1:length(a) );
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top