I have two vectors A & B, and both can be (1xn) matrix.
Will the below code still work: C=cov(x,y); p=C(2)/(std(x)*std(y));
I have two vectors A & B, and both can be (1xn) matrix.
Will the below code still work: C=cov(x,y); p=C(2)/(std(x)*std(y));
I am not sure what you mean by "vectors [...] can be (1xn) matrix" ... aren't all vectors 1-by-n matrices? Do you mean 'as opposed to n-by-1'? Besides, what is keeping you from simply trying it?
>> x=rand(1,100);y=rand(1,100)+x;
>> C=cov(x,y); p=C(2)/(std(x)*std(y))
p =
0.6642
Looks about right to me...
Alternatively, try this:
help corrcoef