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

11 vues (au cours des 30 derniers jours)
Renzo Vallejos
Renzo Vallejos le 13 Avr 2017
Commenté : Stephen23 le 13 Avr 2017
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 commentaires
Guillaume
Guillaume le 13 Avr 2017
" 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.

Connectez-vous pour commenter.

Réponses (2)

Andrei Bobrov
Andrei Bobrov le 13 Avr 2017
out = triu(rand(n))

KSSV
KSSV le 13 Avr 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

Catégories

En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by