필터 지우기
필터 지우기

calculate angle between 2 n-dimentional vectors with missing data

조회 수: 1 (최근 30일)
Brandon
Brandon 2014년 12월 30일
댓글: Matt J 2014년 12월 31일
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
Roger Stafford
Roger Stafford 2014년 12월 31일
Matt, I think you mean
idx = all(~isnan(A),2);
Matt J
Matt J 2014년 12월 31일
Right you are, Roger. I've edited accordingly.

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

카테고리

Help CenterFile Exchange에서 Statistics and Machine Learning Toolbox에 대해 자세히 알아보기

태그

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

Community Treasure Hunt

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

Start Hunting!

Translated by