Scalars, vectors, matrices & tensors

Scalars, vectors, matrices & tensors

A thermostat reading. A drone’s position. A thermal camera. A phone photo.

They seem completely different in the real world—but underneath, they’re all numbers organized in different ways.

As the information becomes more complex, we need more ways to organize those numbers. That takes us from scalar → vector → matrix → tensor.


Scalar

Sometimes, one number is enough.

A room temperature of 22°C can be described completely with a single value. That makes it a scalar.

Scalars appear everywhere: speed, distance, price, battery percentage, temperature, and many other measurements can all be represented by one number.

Set the Thermostat

Turn one number. Watch the room change with it.

Comfort zone · one number describes the room

No matter where you move the slider, the room temperature is still described by one value.

22°C → Scalar

A scalar answers a simple question:

How much?

But one number stops being enough when we need to describe something like a position.


Vector

Imagine telling a delivery drone where to go.

One number cannot describe its position on a flat map. The drone needs both a horizontal position and a vertical position.

We can store those values together:

[x, y]

That ordered list of values is a vector.

For example:

[6, 3]

could mean 6 units across and 3 units up.

Guide the Delivery Drone

Move horizontally and vertically. Two values describe one position.

position = [6, 3]

Move horizontally and one value changes.

Move vertically and another value changes.

Together, the numbers describe one position.

The order matters. [6, 3] and [3, 6] point to different locations because each value has a different role.

Vectors are useful for more than positions. They can represent things like:

  • velocity: [vx, vy]
  • GPS-style coordinates: [latitude, longitude]
  • a pixel’s color: [red, green, blue]
  • a point in 3D space: [x, y, z]

A vector gives us several related values arranged along one axis.

What if we need many values arranged both across and down?

That gives us a matrix.


Matrix

A thermal camera does not measure just one point.

It measures temperatures across an entire area, producing values arranged in rows and columns.

For example:

21  22  24  25
20  23  29  31
19  22  27  28

This two-dimensional grid of numbers is a matrix.

A matrix has two axes:

rows × columns

Each value has a location determined by both its row and its column.

Scan With a Thermal Camera

Point at a location. Every value gets a two-dimensional address.

Selected cell

29°C

row 2 · column 3

Hot radiator detected.

The temperature itself is still a scalar.

But the complete thermal scan contains many temperatures arranged across two axes, so the entire dataset is a matrix.

Matrices show up in many familiar places:

  • spreadsheets
  • grayscale images
  • game maps
  • seating charts
  • sensor grids
  • scientific measurements

A grayscale image, for example, can be stored as a matrix where every number represents the brightness of one pixel.

So a matrix handles rows and columns well.

But a color photo needs something extra.


Tensor

A phone photo may look like one flat image, but the computer stores much more underneath.

Each pixel usually contains separate red, green, and blue values.

That means we can think of the image as three grids stacked together:

  • one red layer
  • one green layer
  • one blue layer

Now the data has three axes:

height × width × channels

This multi-axis collection of values is a tensor.

Unpack the Phone Photo

A color image stores three layers. Pull them apart to see
how tensors organize data.

Pixel (y, x)
y
x
y
x
R
G
B

Each individual color layer is matrix-like.

Stack the three matrices together and you add another axis: color channel.

For example:

1080 × 1920 × 3

could describe an image that is:

  • 1080 pixels high
  • 1920 pixels wide
  • 3 color channels

Tensors can have even more axes.

A video adds time:

time × height × width × channels

A machine-learning model processing several images at once might use:

batch × height × width × channels

This is why tensors are so common in machine learning and deep learning. Images, video, audio, and other complex datasets often need several axes to organize all their values.

The word tensor may sound advanced, but the basic idea is straightforward:

more axes, same basic ingredient: numbers.


The pattern

The easiest way to remember the progression is to focus on how the values are organized.

  • Scalar — one value
  • Vector — values along one axis
  • Matrix — values across two axes
  • Tensor — values organized across additional axes

Think of it as adding structure:

22°C

Scalar: one value

[6, 3]

Vector: an ordered list

21  22  24
20  23  29
19  22  27

Matrix: rows and columns

height × width × channels

Tensor: multiple axes

The numbers themselves are still ordinary numbers. We have simply added more ways to organize them.

A useful question to ask whenever you encounter a new dataset is:

How many axes do I need to organize the values?

That question can often tell you which structure you are looking at.


Match the Real-World Data

Assign each data source to its algebraic structure. Count the axes.

Data Source
Scalar
0D
Vector
1D
Matrix
2D
Tensor
3D+
Elevator current floor: 7
Fitness snapshot: [steps, active minutes, calories]
Tournament scores: teams × games
Warehouse inventory: aisles × shelves × bins
ModuleMachine Learning