Create upper triangular matrix using for loop in matlab

1 回表示 (過去 30 日間)
Elizabeth Brito
Elizabeth Brito 2021 年 1 月 4 日
コメント済み: KALYAN ACHARJYA 2021 年 1 月 4 日
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 件のコメント
Elizabeth Brito
Elizabeth Brito 2021 年 1 月 4 日
Or could you tell me another way to make an upper triangular array with a for loop
KALYAN ACHARJYA
KALYAN ACHARJYA 2021 年 1 月 4 日

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by