How to get Ones along the diagonal

90 Ansichten (letzte 30 Tage)
SIDDESHA H
SIDDESHA H am 29 Dez. 2016
Bearbeitet: David J. Mack am 29 Dez. 2016
I need a matrix of size 5x5 with ones along the diagonal and remaining values to be zero. How to get this.

Antworten (1)

David J. Mack
David J. Mack am 29 Dez. 2016
Bearbeitet: David J. Mack am 29 Dez. 2016
The built-in function DIAG is your friend:
X = diag(ones(5,1))
Greetings, David

Kategorien

Mehr zu Operating on Diagonal Matrices finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by