Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dot product between row vectors by MMULT not working in Excel

I am using Excel to do some dot product between two row vectors:

=MMULT(B1049:M1049, TRANSPOSE(B1050:M1050))

But it does not work, as the cell for the formula shows "#VALUE!". I wonder why? Thanks!

Note that all the cells in "B1049:M1049" and "B1050:M1050" are numbers.

PS: Is this question more suitable here or Superuser?

like image 599
Tim Avatar asked Sep 23 '11 22:09

Tim


People also ask

Why is Mmult not working in Excel?

MMULT Excel Errors (Why is MMULT not working in Excel?)error will occur when the number of columns in array 1 (A below) is not the same as the number of rows in array2 (x below). What is this? To fix this would require that array x has three rows, so it probably means that one of the values from array x is missing.

How do I create a dot product of two vectors in Excel?

For example, two vectors are v1 = [2, 3, 1, 7] and v2 = [3, 6, 1, 5]. The sum of the product of two vectors is 2 × 3 + 3 × 6 + 1 × 1 = 60. We can use the = SUMPRODUCT(Array1, Array2) function to calculate dot product in excel.

How does Mmult function work in Excel?

The MMULT function returns the matrix product of two arrays. The result is an array with the same number of rows as array1 and the same number of columns as array2.


2 Answers

probably simpler, you can just use =SUMPRODUCT(vec1,vec2). This is exactly the Euclidean inner product, without resorting to array formulas.

like image 80
RonnieDickson Avatar answered Oct 24 '22 18:10

RonnieDickson


you need to enter MMULT as an array formula, not as a standard formula

rather then hit enter when you type the formula in pres ctrl-shift-enter and excel will enter it as an array

it will end up looking like
{=MMULT(B1049:M1049, TRANSPOSE(B1050:M1050))}

(please note you can't enter the {} manually)

You may want to look at Excel help which covers this well

like image 40
brettdj Avatar answered Oct 24 '22 18:10

brettdj