Skip to content
Glacius
Linear algebraConcept reference

Matrix shape

Matrix shape lists the number of rows followed by the number of columns.

On this page 7 sections
  1. Overview
  2. A matrix arranges numbers in a rectangle
  3. One row is still a matrix
  4. A shape keeps direction
  5. Key takeaway
  6. Sources & further reading
  7. Concept connections

01A matrix arranges numbers in a rectangle#

A matrix arranges numbers in a rectangle. A row runs across; a column runs down. Its shape records how many of each.

This matrix has 2 rows and 3 columns. Write the row count first: 2×32\times3, read “2 by 3.”

A matrix has rows (4, 0, −2) and (7, 1, 5). The row labels 1, 2 run down its left; column labels 1, 2, 3 run across its top. Its shape is 2 rows by 3 columns, written 2×3.A matrix has rows (4, 0, −2) and (7, 1, 5). The row labels 1, 2 run down its left; column labels 1, 2, 3 run across its top. Its shape is 2 rows by 3 columns, written 2×3.
Figure 1A matrix has rows (4, 0, −2) and (7, 1, 5). The row labels 1, 2 run down its left; column labels 1, 2, 3 run across its top. Its shape is 2 rows by 3 columns, written 2×3.
Link to this figure ↗Download SVGDownload PNG
Check your reasoning

Shape of [501243]\begin{bmatrix}5&0\\1&-2\\4&3\end{bmatrix}?

  1. A2×32\times 3
  2. B3×23\times 2
  3. C6×16\times 1
Show answer and explanation
3×23\times 2

3 rows, then 2 columns.

02One row is still a matrix#

One row is still a matrix. One column is still a matrix. Every position counts, including a zero.

[000]1×3\begin{bmatrix}0&0&0\end{bmatrix}\quad 1\times3
Check your reasoning

How many columns? [000]\begin{bmatrix}0&0&0\end{bmatrix}

Show answer and explanation
3

All three zero entries occupy columns.

03A shape keeps direction#

A shape keeps direction. A 2×32\times3 matrix and a 3×23\times2 matrix each contain 6 entries, but their row and column counts differ.

Check your reasoning

A table has one row per file and one column per feature: 4 files, 2 features. Shape?

  1. A2×42\times 4
  2. B8×18\times 1
  3. C4×24\times 2
Show answer and explanation
4×24\times 2

Files give 4 rows; features give 2 columns.

Key takeaway

Count rows first, then columns; zero entries still count.

  • Identify the row and column dimensions of a matrix.

Sources & further reading

  1. [1]

Reference this concept

Link to this page, a section, or an individual figure.

Glacius. “Matrix shape.” Math behind ML. /learn/la-shape