In Matlab, is there a way to copy lower triangular half of a matrix to upper triangular half?
问题 In Matlab, is there a way to copy lower triangular half of a matrix to upper triangular half? For a square matrix A, I want to be able to do triu(A)=tril(A)'; in order to set all A(i,j) as A(j,i) for i > j. Is there a convenient/efficient way to do this? Note: Preferably, the answer can apply to sparse matrices. On the topic of efficiency, I did some testing regarding the relative time cost for accessing part of a matrix. I used version R2014a Some results: logical indexing is painfully slow