Trying to normalize a matrix across all element values.
43 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
jeet-o
am 27 Jan. 2026 um 20:08
Bearbeitet: dpb
am 29 Jan. 2026 um 17:01
I have the triu of an 8x8 adjacency matrix A shown below. I would LIKE to normallize all the non-zero elements using normalize(A,'range'), for instance with output values between 0 and 1, but NOT column or row-wise - I'd like to normalize across ALL non-zero values. I haven't been able to find options for this. Any help appreciated!
[ 0 54 70 67 18 13 100 18
0 0 89 67 20 37 47 99
0 0 0 38 20 43 49 13
0 0 0 0 26 30 62 27
0 0 0 0 0 11 91 88
0 0 0 0 0 0 17 18
0 0 0 0 0 0 0 4
0 0 0 0 0 0 0 0 ]
0 Kommentare
Akzeptierte Antwort
dpb
am 27 Jan. 2026 um 20:41
M=[ 0 54 70 67 18 13 100 18
0 0 89 67 20 37 47 99
0 0 0 38 20 43 49 13
0 0 0 0 26 30 62 27
0 0 0 0 0 11 91 88
0 0 0 0 0 0 17 18
0 0 0 0 0 0 0 4
0 0 0 0 0 0 0 0 ];
M(M~=0)=rescale(M(M~=0),0,1)
2 Kommentare
Weitere Antworten (1)
Matt J
am 27 Jan. 2026 um 21:01
Bearbeitet: Matt J
am 27 Jan. 2026 um 21:06
Normalize across only non-zero elements, or across elements only in the upper triangle? If the latter, then,
A=[ 0 54 0 67 18 13 100 18
0 0 89 67 0 37 47 99
0 0 0 38 -1 43 49 13
0 0 0 0 26 30 62 27
0 0 0 0 0 11 91 88
0 0 0 0 0 0 17 18
0 0 0 0 0 0 0 4
0 0 0 0 0 0 0 0 ];
idx=triu(true(size(A)),1);
A(idx) = normalize(A(idx),'range')
3 Kommentare
dpb
am 27 Jan. 2026 um 22:32
Bearbeitet: dpb
am 29 Jan. 2026 um 17:01
"the zero scale then ended up zeroing out some "weights" in the adjacency matrix"
That's the solution you asked for -- "I would LIKE to normallize all the non-zero elements ...with output values between 0 and 1,"
What is supposed to be the minimum value then, if not zero? Specify it as the lower bound.
Siehe auch
Kategorien
Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!