Exceljet

Quick, clean, and to the point

Excel MUNIT Function

Excel MUNIT function
Summary 

The Excel MUNIT function returns a unit matrix for a given dimension, n, with a size of n x n. This resulting matrix contains ones on the main diagonal and zeros in every other position.

Purpose 
Return unit matrix for a given dimension
Return value 
Unix matrix of size n x n
Syntax 
=MUNIT (dimension)
Arguments 
  • dimension - An integer for the size of the unit matrix.
Version 
Usage notes 

The MUNIT function returns a unit matrix for a given dimension, n, with a size of n x n. The unit matrix is also called the identity matrix. The MUNIT function takes just one argument, dimension, which should be a positive integer. The resulting matrix contains ones on the main diagonal and zeros in every other position. 

Examples

The formula in D5 returns a 3 x 3 unit matrix :

=MUNIT(3) // 3 x 3

With 3 given for dimension, the MUNIT function returns a 3 by 3 array like this:

1 0 0
0 1 0
0 0 1

The formula in J5 returns a 5 x 5 unit matrix. 

=MUNIT(5) // 5 x 5

With 5 given for dimension, the MUNIT function returns a 5 by 5 array like this:

1 0 0 0 0
0 1 0 0 0
0 0 1 0 0
0 0 0 1 0
0 0 0 0 1

Array syntax

The MUNIT function returns an array of values. In Excel 365, where dynamic arrays are native, you can use the MUNIT function without any special handling – MUNIT will return an array of values that spill directly into cells in the worksheet.

In versions of Excel prior to Excel 365, you need to enter MUNIT enter as a multi-cell array formula to display results directly on the worksheet. To do this, make a selection of the right size, and enter MUNIT with control + shift + enter.

Notes

  • Dimension must be greater than zero.
  • If dimension is zero or less than zero, MUNIT will return the #VALUE error.
  • A unit matrix is also called an identity matrix.

Download 100+ Important Excel Functions

Get over 100 Excel Functions you should know in one handy PDF.