MATLAB Answers

Translated by

이 페이지의 내용은 영어에서 자동 번역되었습니다. 자동 번역 기능을 해제하려면 "<a class="turn_off_mt" href="#" onclick="window._kiq.push(['set', { 'event': 'Turn off MT' }]);">여기</a>"를 클릭하십시오.

James
0

Correlating Two Arrays Using Correcoef

Asked by James
on 9 Apr 2019
Latest activity Commented on by James
on 10 Apr 2019
Accepted Answer by dpb
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

  0 Comments

Sign in to comment.

1 Answers

Answer by dpb
on 9 Apr 2019
 Accepted Answer

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
>>

  1 Comments

Sign in to comment.



Translated by