Effacer les filtres
Effacer les filtres

how to assign the equality relationship for the elements symmetry to the diagnoal of a matrix

2 vues (au cours des 30 derniers jours)
Hi, I have a 4 by 4 matrix which is
x0=[xo(1),xo(2),xo(3),xo(4)
xo(5),xo(6),xo(7),xo(8)
x0(9),xo(10),xo(11),xo(12)
xo(13),xo(14),xo(15),xo(16)]
And I am trying to assign a relationship between elements in this matrix that elements which are symmetry to the diagonal are equal, to be specific, ( i ignored xo),
2=5, 3=9, 4=13, 7=10, 8=14, 12=15. Is is possible to use a for loop to assign this relationship?

Réponse acceptée

Bruno Luong
Bruno Luong le 14 Sep 2019
Modifié(e) : Bruno Luong le 14 Sep 2019
% random test matrix
A = rand(4)
% symmetrize of A by copying the lower part to upper part
B = tril(A)+tril(A,-1).'
for i=1:0 % because you require a for-loop
end

Plus de réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by