File Exchange

## movcorr(x, y, k, varargin): Compute windowed correlation coefficient

version 1.4.0.0 (10.9 KB) by David J. Mack

### David J. Mack (view profile)

Compute a moving correlation for two vectors x & y in analogy to the MOV* functions.

Updated 14 Dec 2017

Computes the Pearson product-moment correlation coefficient r over a moving window for two vectors x & y. This is
basically a wrapper to MOVSUM and the low-memory overhead computation of r. See second formula in
https://en.wikipedia.org/wiki/Pearson_correlation_coefficient#For_a_sample

David J. Mack

### David J. Mack (view profile)

Hey Li Ming,
the input parser has changed its syntax and that's why it does not work with your version of ML... too bad.

li Ming

### li Ming (view profile)

Thanks for your kindly reply. when l run [r, p] = movcorr(rand(100,1), rand(100,1), 11) in Maltalb 2011b, some errors occur as follows:

No appropriate method, property, or field addParameter for class inputParser.

Error in movcorr>parseInputs (line 217)

Error in movcorr (line 107)
[x, y, k, missing, endpoints, tail, nMin, n] ...

will it be the matter of the matlab version l used? Thanks again.

David J. Mack

### David J. Mack (view profile)

Hey Li Ming!
Could you specify what exactly is not working? The syntax resembles the syntax of the built-in MOV* functions (e.g. https://ch.mathworks.com/help/matlab/ref/movmedian.html) as closely as possible. So a toy example would be
[r, p] = movcorr(rand(100,1), rand(100,1), 11)
Hope that helps.

li Ming

### li Ming (view profile)

specify the vector x and y, and specify a Positive integer scalar, but r = MOVCORR(x, y, k) doesn't work. Could you give some examples? Thanks a lot.