Compute Correlation Between Two Matrices
This example shows how to compute correlation between two matrices using 2-D XCORR block.
Example Model
Open the Simulink® model.
open_system('ex_blkxcorr.slx');

The model consists of 5-by-5 and 3-by-3 matrices as inputs. To return correlation values that are computed without zero-padding, the Output size parameter is set to Valid. The range for output correlation value is set to [0 1] by enabling the Normalized output parameter.
Simulate and Display Results
Run the model and display the output value. The output of the model is an array of correlation coefficients. The correlation value signifies the similarity between the values of the input matrices within a chosen window. The correlation coefficient is high (1) when both the input matrices have similar values within a window.
A = sim('ex_blkxcorr.slx');
disp(A.xcorr);
0.6000 0.4472 0.6000
0.6000 1.0000 0.6761
0.2582 0.4472 0.7303