Diagonal Elements of the Square Matrix
Mostrar comentarios más antiguos
I am calculating Sorensen-Dice coefficient (2|A and B|/|A|+|B|) but diagonal elements (intersection with itself) of the square matrix is equal to zero. It is not a big problem but how can I convert them into ones. Thanks for the help.
v = [1 1 0 0 1 1 0; 1 1 0 1 0 0 0; 0 0 0 0 0 1 1]
d = squareform(pdist(v,@(a,b)(2 * sum((a.*b),2))./(sum(a) + sum(b,2))));
Respuesta aceptada
Más respuestas (1)
James Tursa
el 7 de Oct. de 2017
Another way:
M(1:size(M,1)+1:end) = 1;
1 comentario
MB
el 7 de Oct. de 2017
Categorías
Más información sobre Dimensionality Reduction and Feature Extraction en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!