calculate angle between 2 n-dimentional vectors with missing data

2 次查看(过去 30 天)
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

类别

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