Calculating the Pairwise covariance: with NaN's

조회 수: 1 (최근 30일)
Peter Mills
Peter Mills 2017년 12월 5일
댓글: Peter Mills 2017년 12월 6일
I am trying to calculate the pairwise covariance.
x=rand(100,36);
TheNaNC=randi([1 100],1,10);
TheNaNV=randi([1 36],1,10);
x(TheNaNC,TheNaNV)=NaN;
c2 = cov(x,'partialrows');
I get the following error message: 'Error using cov (line 64) The number of elements in x and y must match.'
Also tried:
c3 = cov(x,'omitrows');
'Error using cov (line 64) The number of elements in x and y must match.'
What am I doing wrong with this?
I am trying to calculate the covariance the why R calculate it but using MATLAB
  댓글 수: 4
Torsten
Torsten 2017년 12월 6일
The random integers should be drawn between 1 and 100 (1 and 36), not 0 and 100 (0 and 36).
Best wishes
Torsten.
Peter Mills
Peter Mills 2017년 12월 6일
Ok have changed this. My problem is with calculate the covariance with NaN's in the data without throwing away data

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by