Borrar filtros
Borrar filtros

How to get Ones along the diagonal

38 visualizaciones (últimos 30 días)
SIDDESHA H
SIDDESHA H el 29 de Dic. de 2016
Editada: David J. Mack el 29 de Dic. de 2016
I need a matrix of size 5x5 with ones along the diagonal and remaining values to be zero. How to get this.

Respuestas (1)

David J. Mack
David J. Mack el 29 de Dic. de 2016
Editada: David J. Mack el 29 de Dic. de 2016
The built-in function DIAG is your friend:
X = diag(ones(5,1))
Greetings, David

Categorías

Más información sobre Operating on Diagonal Matrices en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by