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

2 visualizaciones (últimos 30 días)
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 ?

Respuesta aceptada

madhan ravi
madhan ravi el 3 de Mzo. de 2019
a(logical(eye(size(a,1))))=0 % where a is your matrix
  2 comentarios
tomer polsky
tomer polsky el 3 de Mzo. de 2019
thank you for your help but why did you use the logical command ?
madhan ravi
madhan ravi el 3 de Mzo. de 2019
Editada: madhan ravi el 3 de Mzo. de 2019
logical indexing
Alternative (faster):
a(1:size(a,1)+1:end)=0

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by