### 14.3.8 Hadamard product

The hadamard command finds the Hadamard product of two matrices; namely, the term-by-term product of the two matrices.

The product command can do the same thing (see also Section 6.3.27 for other uses of product).

- hadamard takes two arguments: A and B, two matrices of the same size.
- hadamard(A,B) returns the matrix where each element is the product of the corresponding elements of A and B.

The infixed operator .* also finds the Hadamard product, and also works on lists.

#### Examples

hadamard([[1,2],[3,4]],[[5,6],[7,8]])

or:

hadamard([[1,2],[3,4]],[[5,6],[7,8]])

or:

[[1,2],[3,4]].*[[5,6],[7,8]]

⎡
⎢
⎣

5 | 12
21 | 32

⎤
⎥
⎦

[1,2,3,4].*[5,6,7,8]

| ⎡ ⎣ | 5,12,21,32 | ⎤ ⎦