Or we could say something like C 2 comma 5 and comma, 1 colon 2.

So this is take the second row and the fifth row, and then take

the first column up to the second column and this is what we get.

4, 7 is the first column, 5, 8 is the second column.

Finally, if we said capital H equals C, 1 comma 5,

1 comma 5 in this case we would get an error.

The reason we would get an error is because 1 through 5 is

fine for, specifying the rows of C, but how many columns does C have?

C only has three columns.

So, it doesn't make sense to say the first column all the way up to the fifth column.

There is no fourth column and there is no fifth column.

And that's when you're going to, why you're going to get an

error and the error will say index exceeds matrix dimensions.

[BLANK_AUDIO]

Now let's go back to the, that error that we saw

to do before, when we tried to do a matrix multiplication.

Remember when we had A as a two by three array and B as a

two by three array, and then we said capital F is equal to A times B.

We got this error here.

Error using mtimes.

Inner matrix dimensions must agree.

Let's, now let's understand the basis for this error.

[NOISE]

[BLANK_AUDIO]

Now we can understand how matrix multiplication

works mathematically and how it works in MATLAB.

Again if we have A with, as a two by three array, and B as a two by

three array, then we can not multiply a two

by three array, by a two by three array.

So since A and B are both two by three in this case, A times B is undefined.

We'll get an error is we try to do that.

But what if we took b and converted it to a three by two array.

One way we could do that is by using a command known as transpose.

When we type B apostrophe here, B apostrophe means

take the transpose of B, which in practical terms means

turn a row into a column, turn each row

into a column and turn each column into a row.

So B apostrophe or B transpose would look like this.

You see 4, 1, 7, which is the first row of B becomes the first column of B transpose.

And 9, 2, 3 becomes the second column of B transpose.

So, in this, now in this case, A is two by three, and B transposes three by two.

And remember that for, matrix multiplication to

occur, the inner dimensions, matrix dimensions, must agree.

So you can take a two by three

and multiply it by something that's three by two.

So you can compute A times B transpose.

And if we do do that computation in MATLAB, F equals A

times B transpose, we don't get an arrow we get an answer.

And we get this answer, F equals this two by two array, 27, 22, 63, 64.

We can understand each one of these elements as follows.

27 in this case is 1 times 4 plus 2 times 1 plus 3 times 7.

So you take this first row of A, 1, 2, 3 and

you multiply it by this first column of B transpose 4, 1, 7.

And you sum up all the products.

So it's 1 times 4.

2 times 1.

3 times 7, right?

1 time 4 is 4.

2 times 1 is 2.

4 plus 2 is 6.

3 times 7 is 21.

6 plus 21 equals 27.

That's why we got a 27 for the first row and first column, of F in this case.

And all the other elements of, of F are computed similarly.

[BLANK_AUDIO]

So we can understand matrix multiplication a little bit more

generally by, specifying a couple of rules that govern matrix multiplication.

One, as we said, is that multiplication

can only occur if the inner dimensions agree.

And furthermore, what's the, what are the dimensions of our product going to be?

If A is an n by m matrix, and B is an m by p

matrix, then the product A times B is going to have dimensions n times p.

So, the n and the m have to match.

And then what you have, what you start with is

the number of rows you start with in the first matrix.

And the number of columns you end with in the second

matrix, are what you're going to get in your product, n times p.

So we can visualize this as follows.

You can take something that's tall, and skinny,

multiplying it, by something that's short and pretty

fat, and you can end up with a product that's short, sorry that's tall and fat.