Using corrcoef and all p values returned as 1 or 0

Monday, May 12, 2014

I'm trying to test the correlation of 4 sets of data using the corrcoef function in matlab. Each one contains 50 values. Starting out, the data are in a .csv file wtih 4 columns of 50 values each. I've put all 4 sets into a column vector labeled y: y=[[set1] [set2] [set3] [set4]]

So y is a matrix of 4 colums of 50 rows.

I've called the corrcoef function using


When I run this code, I get a 4x4 r matrix with a diagonal of 1's and sets of identical values above or below it, which seems correct because the 1's must be the correlation of one set to itself and the identical values above and below the diagonal are just the correlations of the same two sets repeated (i.e. set2 to set1 vs. set1 to set2).

However, the matrix of p values I return seems all wrong, and I'm not sure why. I get a 4x4 matrix with a diagonal of 1's, and all the values above and below are 0. Clearly this is incorrect because it's saying that the probability of getting the perfect correlations by chance is 100% while getting the "imperfect" correlations by chance is almost impossible.

Can anyone help show me what I'm doing wrong here? I can supply more details if needed.