First argument of XCORR must be a vector?

In the help description of cross-correlation command XCORR, the first argument can be specified as a vector, matrix, or multidimensional array.
But my Matlab 2020b and matlab online threw an error: Error using xcorr (line 93) First argument must be a vector.
The test code is simple as:
xcorr(magic(4), [1; 2; 3;4])

Risposte (1)

Yes, the first parameter to xcorr can be a vector, matrix, or multidimensional array. However, if you look at https://www.mathworks.com/help/matlab/ref/xcorr.html#description you will see that in the case that you pass in two parameters, then both parameters must be vectors.
xcorr(x,y) --> must both be vector
xcorr(x) --> not restricted to vector

1 Commento

Thank you very much. I found it : r = xcorr(x) returns the autocorrelation sequence of x. If x is a matrix, then r is a matrix whose columns contain the autocorrelation and cross-correlation sequences for all combinations of the columns of x.

Accedi per commentare.

Prodotti

Release

R2020b

Richiesto:

il 8 Ago 2021

Commentato:

il 8 Ago 2021

Community Treasure Hunt

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

Start Hunting!

Translated by