Matlab: correlation number
-
29-09-2019 - |
Question
I have a 2 vectors of numbers of either 1 or -1. What are the standard tools on Matlab that would help me calculate a correlation number between the two vectors? Thanks in advance!
Solution
The CORRCOEF function is what you're looking for:
R = corrcoef(vector1(:),vector2(:)); %# Returns a 2-by-2 matrix of
%# correlation coefficients
If you have the Statistics Toolbox, you may also want to check out the function CORR:
RHO = corr(vector1(:),vector2(:)); %# Returns the linear correlation coefficient
%# (default is a Pearson correlation)
OTHER TIPS
The corr function in matlab would switch to Phi-coefficient if it sees binary data.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow