return the row and column of values in a matrix as a single row vector stored in a separate matrix
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Vance Blake
le 12 Nov 2019
Commenté : Vance Blake
le 12 Nov 2019
Hello I have a matrix which I am trying to get the row and column numbers of all values less than 12 in my matrix. I wish to report the row and column numbers of these values as row vectors in separate matrix. So if there is for example there are values that are less than 12 in column 1, row 8 and column 7, row 10 the new matrix would return [1,8;7,10] as its output. The matrix is a symmetric but I only want to do this operation once. I thought of using the upper/lower triangular functions but cannot get my code to ignore the zeros created. Here is the matrix, and thanks for the help.
dist =[NaN 85.8544486266491 94.5151677942934 84.1782439253405 17.8172020987057 86.3318817662466 56.4534611403202 9.03707029380989 51.3456941513557 52.2857876119250
85.8544486266491 NaN 79.0353928689858 62.0983170822968 77.1797933197697 32.0622075437335 29.5507098991569 76.8640139209117 83.7144751456574 34.8061214520901
94.5151677942934 79.0353928689858 NaN 17.2466729715489 76.7467667964011 47.8347591119159 76.6169258553102 89.9428994987178 48.5820092445235 67.3582907248757
84.1782439253405 62.0983170822968 17.2466729715489 NaN 66.9115564731238 31.6800747059846 59.8703139525770 78.4617673106198 45.1634638384781 51.0402083233503
17.8172020987057 77.1797933197697 76.7467667964011 66.9115564731238 NaN 72.2645230957107 49.3715332656335 15.5938323753242 34.3966568539729 42.3815369400674
86.3318817662466 32.0622075437335 47.8347591119159 31.6800747059846 72.2645230957107 NaN 41.5804206339793 78.3848323204859 65.0586469011314 37.5743882661704
56.4534611403202 29.5507098991569 76.6169258553102 59.8703139525770 49.3715332656335 41.5804206339793 NaN 47.4317660338053 63.9187067786962 10.6220215007049
9.03707029380989 76.8640139209117 89.9428994987178 78.4617673106198 15.5938323753242 78.3848323204859 47.4317660338053 NaN 49.8756657320235 43.5443138597632
51.3456941513557 83.7144751456574 48.5820092445235 45.1634638384781 34.3966568539729 65.0586469011314 63.9187067786962 49.8756657320235 NaN 53.5657010496614
52.2857876119250 34.8061214520901 67.3582907248757 51.0402083233503 42.3815369400674 37.5743882661704 10.6220215007049 43.5443138597632 53.5657010496614 NaN];
0 commentaires
Réponse acceptée
JESUS DAVID ARIZA ROYETH
le 12 Nov 2019
solution:
m=tril(dist);
m(m==0)=nan;
[x,y]=find(m<12);
returnn=[x,y]
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur NaNs dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!