Write a MATLAB code that generates a random upper-triangular matrix U of size n.

12 ビュー (過去 30 日間)
Renzo Vallejos
Renzo Vallejos 2017 年 4 月 13 日
コメント済み: Stephen23 2017 年 4 月 13 日
I am new to MATLAB and not sure how to start. please help. Write a MATLAB code that generates a random upper-triangular matrix U of size n.
  2 件のコメント
Guillaume
Guillaume 2017 年 4 月 13 日
" not sure how to start"
By making an effort? This, or something similar, is going to be covered in any book or tutorial about matlab within the first few chapters if not the first.

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

回答 (2 件)

Andrei Bobrov
Andrei Bobrov 2017 年 4 月 13 日
out = triu(rand(n))

KSSV
KSSV 2017 年 4 月 13 日
n = 10 ;
A = zeros(n) ;
for i = 1:n
for j = 1:n
if i<j
A(i,j) = rand ;
end
end
end
Also check triu

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by