Correlation of a vector with a matrix which has columns that are of different size than the vector
조회 수: 13 (최근 30일)
이전 댓글 표시
Hi,
I try to calculate the correlation between a vector let’s say 10x1 and a matrix 10x2 but in the matrix the second column only starts at the 3rd value. Using the corr function I get a value for the first correlation but a NaN for the second one. Is there a way to somehow adjust the vector to the size of the 2nd column to also compute the correlation with it? In my real problem the matrix is way bigger and almost every column has some values missing but only at the beginning.
Thank you in advance!
댓글 수: 0
답변 (1개)
Ngoc Tran
2018년 4월 2일
A = rand(10,1);
B = rand(10,2);
B(1:2,2) = NaN;
corr(A,B,'rows','complete')
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!