identity
identity(n)
identity(m, n)
identity([m, n])
Returns the identity matrix with size m-by-n. The matrix has ones on the diagonal and zeros elsewhere.
Try it yourself:
$1 | identity(3)
| |
$2 | identity(3, 5)
| |
$3 | a = [1, 2, 3; 4, 5, 6]
| |
$4 | identity(size(a))
|