Effacer les filtres
Effacer les filtres

calculate angle between 2 n-dimentional vectors with missing data

2 vues (au cours des 30 derniers jours)
Brandon
Brandon le 30 Déc 2014
Commenté : Matt J le 31 Déc 2014
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.

Réponses (1)

Matt J
Matt J le 30 Déc 2014
Modifié(e) : Matt J le 31 Déc 2014
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 commentaires
Roger Stafford
Roger Stafford le 31 Déc 2014
Matt, I think you mean
idx = all(~isnan(A),2);
Matt J
Matt J le 31 Déc 2014
Right you are, Roger. I've edited accordingly.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Genomics and Next Generation Sequencing dans Help Center et File Exchange

Tags

Aucun tag saisi pour le moment.

Community Treasure Hunt

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

Start Hunting!

Translated by