title: Pearson's Coefficient and Covariance calculation in Matlab
body: <p>I want to calculate <a href="http://en.wikipedia.org/wiki/Pearson_product-moment_correlation_coefficient" rel="noreferrer">Pearson's correlation coefficent</a> in Matlab (without using Matlab's <code>corr</code> function). </p>
  
  <p>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>
  
  <pre><code>P = cov(x, y)/std(x, 1)std(y,1)
  </code></pre>
  
  <p>I am using Matlab's <code>cov</code> and <code>std</code> functions. What I don't get is, the cov function returns me a square matrix like this:</p>
  
  <pre><code>corrAB =
      0.8000    0.2000
      0.2000    4.8000
  </code></pre>
  
  <p>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?</p>