문제

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!

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top