Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pearson's Coefficient and Covariance calculation in Matlab

Tags:

I want to calculate Pearson's correlation coefficent in Matlab (without using Matlab's corr function).

Simply, I have two vectors A and B (each of them is 1x100) and I am trying to calculate the Pearson's coefficient like this:

P = cov(x, y)/std(x, 1)std(y,1)

I am using Matlab's cov and std functions. What I don't get is, the cov function returns me a square matrix like this:

corrAB =
    0.8000    0.2000
    0.2000    4.8000

But I expect a single number as the covariance so I can come up with a single P (pearson's coefficient) number. What is the point I'm missing?