How to directly create a non-random upper or lower triangle matrix without creating a full square matrix?
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I want to create the upper triangle matrix only directly in matlab and reflect it to make a full square matrix. I will assign numerical values to all the variables listed in the matrix.
0 Kommentare
Antworten (1)
Rishabh Mishra
am 4 Nov. 2020
Bearbeitet: Rishabh Mishra
am 4 Nov. 2020
Hi,
Consider the upper triangular matrix created below:
A = [1 2 3 4; 0 5 6 7; 0 0 8 9; 0 0 0 10];
To create the mirror image of upper triangle into the lower triangle, use the code below:
for i = 1:size(A,1)
for j = 1:size(A,1)
if j < i
A(i,j) = A(j,i);
end
end
end
Hope This helps.
2 Kommentare
Siehe auch
Kategorien
Mehr zu Matrices and Arrays finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!