How do I get one correlation coefficient of R value in MatLab?

20 次查看(过去 30 天)
Hi all am new to matlab, so this maybe a very stupid question to some..
When I use excel to calculate the correlation i get one R value. How do I do this in MatLab? I am using the code below R=(corrcoef(xdata,ydata)); xdata is a 5 by 1 and ydata is also 5 by 1 am getting the result below 1.0000 0.5356
0.5356 1.0000
not sure what this results means ones on the diagonal, as I only want a single value of R..
Can someone please explain to me what am doing wrong or how can I get a single R value.

回答(1 个)

Star Strider
Star Strider 2012-7-22
Not stupid at all. The values are the correlations of the various columns (by number) with each other. The ones on the diagonal are the correlations of each variable with itself. So in your [2 x 2] situation, where the function is treating ‘xdata’ as one column and ‘ydata’ as the other, the values you want are R(2,1) or R(1,2). (The matrix is symmetric.)

类别

Help CenterFile Exchange 中查找有关 Operating on Diagonal Matrices 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by