matlab求相关系数输出nan,Matlab:为什么使用'corrcoef'时相关NaN? - matlab代码 - 源码查...

问题

When I run corrcoef to find correlation coefficients among two data arrays, I get NaNs. It only does that for one batch of data. Here is a download link to the data within .mat file.

I run this code

[R(1).R,R(1).P,R(1).RL,R(1).RU] = corrcoef([data.Series1], [data.Series2], 'rows', 'pairwise');

and it gives me

NaN NaN

NaN 1

for R, P, RL, and RU.

I don't think the NaNs in the data are the problem because I use 'pairwise' parameter for corrcoef function, which tells it to ignore NaNs.

I copied the same data into Microsoft Excel and it calculated the correlation coefficient just fine. Here is the Excel file with the coefficient of correlation calculated. Why doesn't corrcoef do it? What can possibly go wrong here?

解决方法

I had to download this file and plug it in to see what happened.

Yes you are right that when

你可能感兴趣的:(matlab求相关系数输出nan,Matlab:为什么使用'corrcoef'时相关NaN? - matlab代码 - 源码查...)