Question

I have a matrix-form data stored in a CSV file, and it looks like this,

enter image description here

I want to make this 6 * 6 matrix be a symmetric matrix, like this,

enter image description here

How to use python (or matlab) to change an n by n matrix (square matrix) to a symmetric matrix? Or are there other tools can do this?

Please give me any suggestion, thank you!

Était-ce utile?

La solution

In MATLAB, for an upper-triangular matrix A you can write

>> B = A' + triu(A,1)

where triu(A,1) extract the upper-triangular part without the diagonal - you do not want that to be doubled.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top