Simple Excel 97 Question

Thanks much for the help. I’ll try it out.

Sorry, how does that work again?

Matrix multiplication:

[A]** = [C]

A is an mxn matrix (m rows, n columns)
B is an nxp matrix (n rows, p columns)
C will be mxp

Note how the columns of A match the rows of B. This must be true for matrix multiplication.

C(i,j) = Sum(A(i,x)*B(x,j)) for x = 1 to n

This equation is confusing, but what it boils down to is this:

To calculate an element in C, you move along the rows of A and down the columns of B, adding up the results of the multiplication. A good text can explain this better than I can right now. I need paper to draw with.

Example:

A = 1 2 3
4 5 6

B = 2 3
8 9
1 1

A is 2x3
B is 3x2

C will be 2x2

C(1,1) = A(1,1)B(1,1) + A(1,2)B(2,1) + A(1,3)B(3,1)
= 1
2 + 2
8 + 3
1
= 2 + 16 + 4
= 21

Note how we go across the first row of A, and down the first column of B.
C(1,2) = 13 + 29 + 3*1 = 24

C(2,1) = 42 + 58 + 6*1 = 54

C(2,2) = 43 + 59 + 6*1 = 63

C = 21 24
54 63

To do this in excel:

Enter the A matrix anywhere.
Enter the B matrix anywhere.

Move the cursor to some area with 2x2 cells open. Highlight them. Enter:
=MMULT((HIGHLIGHT A MATRIX, HIGHLIGHT B MATRIX))
then hold down the shift,ctrl and enter keys.

I can email an example if you wish, but I doubt it will make much sense without seeing the the keystrokes.

If C = AB, c[sub]ij[/sub] is the dot product of a[sub]i[/sub] and b[sub]j[/sub].

If you’re comfortable with VBA, you could write a macro to do this. It’d take me a while, but it’s worth looking into.

Maybe if the itch gets big enoug :slight_smile:

I use excel all day every day so I’ll see if I can help.

Firstly, excel has a limited number of columns, so your matrix number of colums will be limited by this. Assuming that you have less rows than this then this is what I would do.

Start your two columns in cells A2 and B2 going downwards. Select and highlight column 1 (Put your cursor in cell A2 and hold Ctrl+Shift and hit down) Hit Ctrl C to copy, then move to cell C1 and hit Alt then e then s then e then enter. (Paste special transpose, you should see your column stretching as a row to the right) Now in cell C2 type

=$B3+C$1

If you now highlight your whole matrix, from C2 right and down and hit Ctrl R and then Ctrl D to fill the formulas out.

You can easily do this with offset functions as well, but why bother as it is so much harder to check the formulas