Math & trig function

MUNIT function

Returns an identity matrix of the given size: 1s on the diagonal, 0s elsewhere.

Available in Excel 2013 and later; spills in Microsoft 365 and Excel 2021+

Excel 2013 and laterWorks in Google Sheets

Syntax

MUNIT(dimension)
ArgumentWhat it means
dimensionRequiredThe number of rows and columns (a positive integer).

Returns: A square array that spills into neighbouring cells.

How MUNIT works

MUNIT builds the identity matrix: a square grid with 1 on the main diagonal and 0 everywhere else. It is the matrix equivalent of the number 1, because any matrix multiplied by it stays unchanged. That makes it useful for checking an inverse, since MMULT(A, MINVERSE(A)) should equal MUNIT(n).

It is also handy outside matrix algebra: MUNIT(5) is a quick 0/1 pattern for a diagonal, for example to mark self-comparisons in a distance table or to build a schedule where each person is assigned to exactly one slot. A dimension of 0 or less returns #VALUE!.

Examples

1A 3 × 3 identity matrix

A1fx=MUNIT(3)
ABC
1100
2010
3001

Three rows and columns with ones on the diagonal.

2Check that an inverse is correct

E2fx=ROUND(MMULT(B2:C3, MINVERSE(B2:C3)), 10)=MUNIT(2)
ABCDEF
1MatrixCol 1Col 2
2Row 147TRUETRUE
3Row 226TRUETRUE

Multiplying the matrix by its inverse gives the identity. ROUND removes floating-point noise before comparing with MUNIT(2).

⬇Practice workbookExamples with live formulas + practice sheets · .xlsx · 14 KB

Common errors and how to fix them

ErrorWhy it happensFix
#VALUE!dimension is 0 or negative.Use a positive integer.

Tips

  • Scaled diagonal matrix: =MUNIT(3)*5.

Google Sheets

MUNIT also exists in Google Sheets and works the same way for everyday use, so the examples above work there too.

MUNIT in other languages

In a non-English version of Excel the function has a local name. Excel translates formulas automatically when a file is opened in another language.

LanguageFunction name
DanishMENHED
DutchEENHEIDMAT
FinnishYKSIKKÖM
FrenchMATRICE.UNITAIRE
GermanMEINHEIT
HungarianMMÁTRIX
ItalianMATR.UNIT
Norwegian (Bokmål)MENHET
PolishMACIERZ.JEDNOSTKOWA
Portuguese (Portugal)UNIDM
RussianМЕДИН
SpanishM.UNIDAD
SwedishMENHET
TurkishBİRİMMATRİS