How can I get elegantly an upper triangle random matrix (0 elsewhere)?

2 visualizzazioni (ultimi 30 giorni)
I have seen the triu and tril functions, but I can't use them to set to 0:
A = rand(4);
tril(A)=0; % won't work
any idea, other than using 2 for loops?

Risposta accettata

Andrei Bobrov
Andrei Bobrov il 31 Mag 2014
Modificato: Andrei Bobrov il 31 Mag 2014

Più risposte (0)

Categorie

Scopri di più su Operating on Diagonal Matrices in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by