필터 지우기
필터 지우기

Averaging over a symmetric matrix

조회 수: 1 (최근 30일)
MiauMiau
MiauMiau 2017년 8월 14일
댓글: MiauMiau 2017년 8월 14일
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)
  댓글 수: 1
MiauMiau
MiauMiau 2017년 8월 14일
yes triu I meant! thanks for the hint!

댓글을 달려면 로그인하십시오.

추가 답변 (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