Matrix equality compares both structure and content. Matching values are not enough if they occupy different positions or if the matrices have different dimensions.
Matrices A and are , written , if and only if both conditions below hold:
B
equal
A=B
Same dimensions: Matrix A and matrix B must have the same number of rows and columns. If A has dimensions m×n, then B must also have dimensions m×n.
Corresponding Elements are Equal: Every corresponding element (located in the same row and column position) in matrix A and matrix B must have the same value. If A=[aij] and B=[bij], then for all values of (row index) and (column index).
If one of these two conditions is not met, then matrix A is not equal to matrix B (written as A=B).
Matrix equality is decided by two checks. The two matrices must have the same format, and then every entry at the same position must match. The examples below show one pair that passes both checks and two pairs that fail exactly one of them, followed by a case where the entries contain unknown variables.
Although matrix S and matrix T have the same dimensions, 2×2, they are not equal (S=T). Their entries in row 2, column 1 differ: s21=−2, whereas t21=2.