Create upper triangular matrix using for loop in matlab

v = 1:6;
n = round((sqrt(8 * numel(v) + 1) - 1) / 2);
M = zeros(n, n);
c = 0;
for i2 = 1:n
for i1 = 1:i2
c = c + 1;
M(i1, i2) = v(c);
end
end
I found this code to make an upper triangular matrix, but I don't understand what the code is trying to say to make it work can someone explain to me

댓글 수: 2

Or could you tell me another way to make an upper triangular array with a for loop

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

답변 (0개)

카테고리

도움말 센터File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

질문:

2021년 1월 4일

댓글:

2021년 1월 4일

Community Treasure Hunt

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

Start Hunting!

Translated by