I suggest two things to show the overall correlation, in Matlab. Let the x1
, x2
vectors denote your data.
- Compute
c = corrcoef(x1,x2)
and observec(2,1)
. That's the correlation coefficient for the whole vectors. It measures correlation normalized between -1 and 1. plot(x1,x2,'.','markersize',3)
. That draws a cloud of points, from which you can visually assess the correlation. For correlatedx1
andx2
, the points tend to form a more or less thin cloud along a straight line (see example shapes and its associated correlation coefficient)
If your vectors contain NaN
's, you should first remove them:
ind = ~(isnan(x1)|isnan(x2));
x1 = x1(ind);
x2 = x2(ind);
For example: the following two example vectors give c=0.91
, and the cloud shape makes it obvious that there is significant correlation: