Averaging over a symmetric matrix

5 次查看(过去 30 天)
Hello,
Given an m,n matrix, I want to create a new matrix by doing the following: The element (i,d) and the element (d,i) should be averaged, the diagonal elements can be ignored. So for instance we average over element (1,5) and (5,1) which gives us a new (single entry) and hence a smaller matrix at the end - how can that be done in a quick way (not too many loops)?

采纳的回答

Guillaume
Guillaume 2017-8-14
编辑:Guillaume 2017-8-14
I don't see how you get a smaller matrix but doing the averaging is trivial:
(yourmatrix + yourmatrix.') / 2
You can triu or tril that result to keep the upper or lower triangle since it's symmetric.
And of course, it only works with square matrix otherwise there won't always be an (i,d) for a (d,i)

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Operating on Diagonal Matrices 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by