Borrar filtros
Borrar filtros

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

20 visualizaciones (últimos 30 días)
yasmin
yasmin el 22 de Jul. de 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.

Respuestas (1)

Star Strider
Star Strider el 22 de Jul. de 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.)

Categorías

Más información sobre Operating on Diagonal Matrices en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by