CBSE 2026 results are out, Mukul scored a perfect 100/100 in Computer ScienceSee all toppers →

KwickAcademy Artificial Intelligence · 7 min · free

Matrices for AI

7 min4 KwickClipsFull text belowFree
Kajal Ma'am (MCA), teaching since 2004Remembered in this browser

A matrix is a rectangle of numbers in rows and columns. Every digital image is stored as a matrix of pixel values. Neural network layers multiply a weight matrix by the inputs and add a bias.

Follows the syllabus of: CBSE Class 11 Artificial Intelligence (843), CBSE Class 12 Artificial Intelligence (843)

On screen in this lesson

What is a matrix?

A rectangle of numbers in rows and columns
Rows go across, columns go down
Order is written as rows x columns
Each number is called an element

A marks table is a matrix

StudentMathsScience
Riya8275
Aman6490
Neha7168

Why an image is a matrix

An image is made of tiny dots called pixels
Grayscale: one number per pixel, 0 black to 255 white
Colour: three matrices, for red, green and blue
A 100 by 100 photo has 10,000 pixels

Adding two matrices

Both matrices must have the same order
Add the elements in the same position
The answer has the same order too

Multiplying two matrices

Columns of the first = rows of the second
Take a row of the first and a column of the second
Multiply matching pairs and add them up
A (2 x 3) times B (3 x 4) gives a 2 x 4 matrix
A x B is usually not equal to B x A

Transpose of a matrix

Rows become columns, columns become rows
Written as A with a small T on top
A 2 x 3 matrix becomes 3 x 2
Transpose twice gives back the original

Quick answers

When can two matrices be multiplied?

When columns of the first equal rows of the second.

What order is the transpose of a 2 x 3 matrix?

3 x 2.

KwickClips from this lesson

Short clips, one idea each. Good for revision the night before.

The full lesson, in text

Hello students, welcome to Kwickprep. When you click a selfie, what does the computer actually see? It does not see a face. It sees a grid of numbers called a matrix. Today we learn what a matrix is and how to add and multiply matrices. We also learn the transpose, and how matrices work inside a neural network.

Let us start with the meaning of a matrix. A matrix is a rectangle of numbers arranged in rows and columns. Rows go across from left to right, and columns go down from top to bottom. The size of a matrix is called its order, written as rows by columns. Each single number inside a matrix is called an element.

You already use matrices every day, maybe without knowing it. Riya scored eighty two in maths and seventy five in science. Aman scored sixty four and ninety. Neha scored seventy one and sixty eight. Remove the names and headings, and the numbers form a matrix with three rows and two columns. So its order is three by two.

Now, why do we say an image is a matrix? Every digital image is made of tiny coloured dots called pixels. In a black and white, or grayscale, image, each pixel is one number from zero for black to two hundred fifty five for white. A colour image keeps three matrices, one each for red, green and blue. So a small photo of one hundred by one hundred pixels holds ten thousand numbers in each matrix.

Here is a tiny grayscale image of just three by three pixels. Zero is black and two hundred fifty five is white. Look at where the white values sit. They form a plus sign in the middle of a black square. This is exactly how a computer vision model receives a picture, as a matrix of numbers.

Let us learn the first operation, matrix addition. Two matrices can be added only when they have the same order. We add the elements that sit in the same position, row with row and column with column. The answer is a matrix of the same order.

Here the first matrix holds the marks of two students in unit test one, and the second holds unit test two. In Python, a matrix can be stored as a list of rows. Twenty plus twenty five is forty five, and fifteen plus ten is twenty five. The second row gives thirty and forty two. The sum matrix is also two by two.

Matrix multiplication follows a different rule, so listen carefully. The number of columns in the first matrix must equal the number of rows in the second. To find one answer element, take a row of the first matrix and a column of the second. Multiply the matching pairs and add the results. A two by three matrix times a three by four matrix gives a two by four matrix. Also remember, A times B is usually not the same as B times A.

Let us work one example together. Take row one, which is one and two, and column one, which is five and seven. One times five plus two times seven gives nineteen. Row one with column two gives one times six plus two times eight, which is twenty two. Row two with column one gives forty three. Pause the video and work out the last element yourself.

The last element is fifty, because three times six plus four times eight is fifty. Here is a real use of row times column. Two friends buy samosas at fifteen rupees and tea at ten rupees. The qty matrix holds quantities, and the second list holds the prices. The first friend buys two samosas and one tea, so the bill is forty rupees. The second buys one samosa and three teas, so the bill is forty five rupees.

Next, the transpose. The transpose turns every row into a column, and every column into a row. We write it as A with a small capital T on top. So a two by three matrix becomes a three by two matrix. If you take the transpose twice, you get back the original matrix.

Matrix a has two rows and three columns. Its first row is one, two, three. After the transpose, that row becomes the first column. So the answer has three rows and two columns. In AI code, the transpose helps us line up shapes so that multiplication is allowed.

Now let us see where matrices live in AI. A neural network is a model made of layers of small units called neurons. The inputs to a layer are stored as a column of numbers. The weights, which show how important each input is, form a weight matrix, written capital W. Each layer multiplies W by the inputs and adds a bias, which is an extra number. Then an activation function, a simple rule, shapes the final output.

Here is one layer with two inputs and two neurons. The input list holds attendance eighty and homework score fifty. Each row of W holds the weights of one neuron. Neuron one gives point five times eighty, plus point two times fifty, plus one, which is fifty one. Neuron two gives thirty. Real networks do this with millions of numbers, which is why AI runs on fast chips built for matrix work.

Let us revise what we learned today. A matrix is a rectangle of numbers, and every image is stored as one. To add matrices, the order must match, and we add matching elements. To multiply, we take a row of the first and a column of the second. The transpose turns rows into columns. And every layer of a neural network multiplies a weight matrix by its inputs. Try multiplying two small matrices on paper today.

Courses that teach this

CourseUnit
CBSE Class 10 Artificial Intelligence (417)Part B Unit 3: Evaluating Models
CBSE Class 11 Artificial Intelligence (843)Data Literacy — Data Collection to Data Analysis
CBSE Class 12 Artificial Intelligence (843)Data Science Methodology - An Analytic Approach to Capstone Project

Voice-over in this lesson is AI-generated. The script is written and checked by Kajal Ma'am. Boards can revise a syllabus mid-year, so confirm anything you plan around against the official board circular. Keep your passwords, OTPs and ID numbers to yourself — we never ask for them. To reach Kajal Ma'am, use the WhatsApp button; sharing your number there is how we call you back.

Free to watch, no sign-up. Live classes with Kajal Ma'am are the paid course; these lessons stay free either way.

Want a plan that actually fits your board dates?

Ask Kajal Ma'am directly, 20+ years teaching computer science. Free demo class first, no payment.

Talk to Kajal Ma'am on WhatsApp

Or see the Class 12 Computer Science course →

Studying outside India?

We coach CBSE, IGCSE & international students across the globe, one-to-one, in your local time zone.

Visit International →