calculate angle between 2 n-dimentional vectors with missing data

I have a matrix with the rows containing the n dimensions of 2 vectors. I want to calculate the angle of difference for each row. The issue I have is that some of the cells are missing and so I don't want either of the vectors values for that dimension in the row to go into the calculation.

답변 (1개)

Matt J
Matt J 2014년 12월 30일
편집: Matt J 2014년 12월 31일
So your matrix A is n x 2 and your the missing elements are NaNs? If so,
idx = all(~isnan(A),2); %EDITED
B=A(idx,:);
norms = prod(sqrt(sum(B.^2)));
dotprod= sum(prod(B,2));
result = acosd( dotprod/norms), %angleDiff

댓글 수: 2

Matt, I think you mean
idx = all(~isnan(A),2);
Right you are, Roger. I've edited accordingly.

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

카테고리

도움말 센터File Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

질문:

2014년 12월 30일

댓글:

2014년 12월 31일

Community Treasure Hunt

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

Start Hunting!

Translated by