corr returns NaN
18 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
D
el 7 de Jul. de 2011
Respondida: Bio_Ing_Sapienza
el 24 de Feb. de 2019
I'm calculating the correlation coefficient between two vectors, using corr. It returns NaN, and I'm curious to know why that is the case.
c and d are the vectors.
>> [c d]
ans =
1 1
2 1
2 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
2 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
0 comentarios
Respuesta aceptada
Sean de Wolski
el 7 de Jul. de 2011
read the:
doc corr
and you'll see it's not what you want. Are you looking for :
doc corrcoef %?
3 comentarios
Sean de Wolski
el 7 de Jul. de 2011
It's because there's no variance/ standard deviation in the second column and thus in the correlation coefficient calculation when you divide by std or var (however it's implemented) you're in turn dividing zero by zero which yield nan.
Más respuestas (1)
Bio_Ing_Sapienza
el 24 de Feb. de 2019
Maybe you have to ceck for "Inf" components in your array. Sometimes I was searching from Nan even if I had already checked them out. But there are other kind of Matlab numeric representation for results came from division that yields to too large numbers to be represented with floating number. So check also for these ones!
0 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!