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

2 Ansichten (letzte 30 Tage)
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?

Akzeptierte Antwort

Andrei Bobrov
Andrei Bobrov am 31 Mai 2014
Bearbeitet: Andrei Bobrov am 31 Mai 2014

Weitere Antworten (0)

Kategorien

Mehr zu Operating on Diagonal Matrices finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by