Matrix Multiplication in Excel Vba
Matrix Multiplication in Excel Vba
in Excel vba
Finding a matrix product AB
Suppose A is an n × m matrix and B is an m × p matrix. The order of AB is then n × p.
To find AB in Excel, simply enter the numbers in the matrices anywhere on your spreadsheet.
Perform the following steps:
• Select an empty n × p block of cells in your spreadsheet(if you know your matrix product
is an n × p matrix).
• Press the “F2” key.
• Press the “=” sign.
• Type in “MMULT(”.
• Select the cells containing A and enter a comma (,).
• Select the cells containing B.
• Close the bracket “)”.
• Hold down the keys “Ctrl” and “Shift” at the same time and press the “Enter” key while
holding down the other two.
Notice that Matrix A is in cells B2:D3, and Matrix B in cells G2:H4
b) We multiply Row by Column and the first matrix has 2 rows and the
second has 2 columns, so the resulting matrix will have 2 rows by 2
columns.. Highlight the cells where you want to place the resulting matrix
E:
c) Once you have highlighted the resulting matrix, and while it is still highlighted,
enter the following formula:
=MMULT(B2:D3,G2:H4)
d) When the formula is entered, press the Ctrl key and the Shift key simultaneously,
then press the Enter key. This will change the formula you just wrote to:
{=MMULT(B2:D3,G2:H4)}
If you don't press these keys simultaneously (holding down Shift and Ctrl then press
Return), the result will appear only in one cell or, you will get some error message).
e) The resulting matrix will be:
To find A2, A3, A4 and A8.
The answers can be found as: