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

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


Updated 14 Dec 2017

View License

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

Cite As

David J. Mack (2023). movcorr(x, y, k, varargin): Compute windowed correlation coefficient (, MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2015a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

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

Start Hunting!
Version Published Release Notes

- Now returns NaN for zero-variances, to be consistent with CORR.

- Output n to return the local window sizes (useful for computing partial correlations).
- Name-value input 'MinN' to control how many samples are needed in a local window to compute r.

Fix in input parser.
- Name-value input 'Tail' and according p-value output.
- Now uses INPUTPARSER. Changes error messages for invalid inputs.
- Erroneous window size computation when using k = [nB, nF].
- Complex output when using numeric endpoints.

Forgot file update
Computation of r with NaNs + omitnan flag now gives same results as CORR(...,'Rows','pairwise').

Added ML-FEX ID to description.