MATLAB Answers

how to insert diganole of zeros in to matrix without using loops ?

2 views (last 30 days)
tomer polsky
tomer polsky on 3 Mar 2019
Edited: madhan ravi on 3 Mar 2019
my question is simple how to change the main diagonel of nXn of random numers and change the main diagonle to zeroes ?
without using loops ?

  0 Comments

Sign in to comment.

Accepted Answer

madhan ravi
madhan ravi on 3 Mar 2019
a(logical(eye(size(a,1))))=0 % where a is your matrix

  2 Comments

tomer polsky
tomer polsky on 3 Mar 2019
thank you for your help but why did you use the logical command ?

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!