Effacer les filtres
Effacer les filtres

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

20 vues (au cours des 30 derniers jours)
yasmin
yasmin le 22 Juil 2012
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.

Réponses (1)

Star Strider
Star Strider le 22 Juil 2012
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.)

Catégories

En savoir plus sur Operating on Diagonal Matrices dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by