corr
Compute correlation coefficients.
Syntax
c = corr(x)
c = corr(x,y)
Inputs
- x
- Data sample.
- y
- Data sample.
Outputs
- c
- Correlation coefficient.
Example
a=[1,2,3,4;1,4,9,16;16,9,4,1;1,8,27,64];
b=[2,3,4;4,9,16;8,27,64;16,9,4];
c=corr(a,b)
c = [Matrix] 4 x 3
0.053838 0.96225 0.9802
0.774 0.78633 0.61452
0.8863 -0.21581 -0.44596
0.85931 -0.28643 -0.51024
Comments
When x is a matrix c=corr(x) computes matrix c such that c(i,j) is the correlation coefficient of columns i and j of x.
When x and y are vectors c=corr(x,y) computes the correlation coefficient of the vectors.
When x and y are matrices c=corr(x,y) computes matrix c such that c(i,j) is the correlation coefficient of column i of x and column j of y.