Effacer les filtres
Effacer les filtres

How to get Ones along the diagonal

38 vues (au cours des 30 derniers jours)
SIDDESHA H
SIDDESHA H le 29 Déc 2016
Modifié(e) : David J. Mack le 29 Déc 2016
I need a matrix of size 5x5 with ones along the diagonal and remaining values to be zero. How to get this.

Réponses (1)

David J. Mack
David J. Mack le 29 Déc 2016
Modifié(e) : David J. Mack le 29 Déc 2016
The built-in function DIAG is your friend:
X = diag(ones(5,1))
Greetings, David

Catégories

En savoir plus sur Operating on Diagonal Matrices dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by