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

12 views (last 30 days)
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.

Answers (2)

Andrei Bobrov
Andrei Bobrov on 13 Apr 2017
out = triu(rand(n))

KSSV
KSSV on 13 Apr 2017
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

Categories

Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!