arabhi manachra
arabhi manachra

Reputation: 137

Correlation between three variables in MATLAB

In MATLAB, I have the following:

A, B, C are 1 x 101 row vectors. I know that for 'i' from 1 to 101, A(i), B(i), and C(i) are linearly correlated.

How can I identify the dependence between A, B, and C?

Upvotes: 1

Views: 5002

Answers (1)

eigenchris
eigenchris

Reputation: 5821

For the degree of correlation, you can use corrcoef:

data = [A(:) B(:) C(:)];
correlation = corrcoef(data);

Here's a test case that shows positive/negative correlation as well as the degree of correlation, with

N = 10000;
A = randn(N,1);
B =  3*A + randn(N,1);
C = -2*A + 20*randn(N,1);

correlation =

    1.0000    0.9473   -0.1005
    0.9473    1.0000   -0.0927
   -0.1005   -0.0927    1.0000

Upvotes: 4

Related Questions