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

12 次查看(过去 30 天)
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 个)

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 CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by