MATLAB Answers

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

1 view (last 30 days)
cyril on 31 May 2014
Edited: cyril on 31 May 2014
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?

More Answers (0)

Community Treasure Hunt

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

Start Hunting!