Trying to normalize a matrix across all element values.
44 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
jeet-o
el 27 de En. de 2026 a las 20:08
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 comentarios
Respuesta aceptada
dpb
el 27 de En. de 2026 a las 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 comentarios
Más respuestas (1)
Matt J
el 27 de En. de 2026 a las 21:01
Editada: Matt J
el 27 de En. de 2026 a las 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 comentarios
dpb
el 27 de En. de 2026 a las 22:32
Editada: dpb
el 29 de En. de 2026 a las 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.
Ver también
Categorías
Más información sobre Matrix Indexing en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!