質問

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