Correlating Two Arrays Using Correcoef

3 visualizaciones (últimos 30 días)
James
James el 9 de Abr. de 2019
Comentada: James el 10 de Abr. de 2019
I am attempting to correlate two arrays using function = corrcoef. When I employ the function, I end up with a matrix that looks like the one below. The arrays are the same size. What could be the reason for the error? When I plot them as a scatter, there is clearly little correlation, but it would be nice to know the correlation coeffecient.
R_32 =
1 NaN
NaN NaN

Respuesta aceptada

dpb
dpb el 9 de Abr. de 2019
There's at least one NaN in the second variable...you don't give any information about which is which.
>> spd=5*rand(500,1);tlt=randn(500,1)/5;
>> scatter(tlt,spd)
>> corrcoef(tlt,spd)
ans =
1.00 0.06
0.06 1.00
>> spd(1)=nan;
>> corrcoef(tlt,spd)
ans =
1.00 NaN
NaN NaN
>>
NaN values are just silently ignored by plot routines so that won't show up anything unusual...use the 'rows' optional parameter to skip NaN in the input...
>> corrcoef(tlt,spd,'rows','complete')
ans =
1.00 0.06
0.06 1.00
>>

Más respuestas (0)

Categorías

Más información sobre Descriptive Statistics en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by