*
Matrix multiplication operator.
Category: Language Fundamentals > Operators and Elementary Operations
Syntax
C = A * B
Matrix product of A and B. Same as mtimes(A, B).
Description
The number of columns of A must equal the number of rows of B, otherwise MatLivre reports an error about incompatible dimensions. If either operand is a scalar, * multiplies every element, just like .*.
A row times a column gives a scalar (the dot product) and a column times a row gives a matrix (the outer product). For element by element products use .*.
Input arguments
A- Numeric or logical matrix,
m-by-k, or a scalar. B- Numeric or logical matrix,
k-by-n, or a scalar.
Output arguments
C- The
m-by-nproduct withC(i,j) = sum(A(i,:) .* B(:,j)).
Example
A = [1 2; 3 4];
A * [1; 1]
A * A
[1 2 3] * [4; 5; 6]
[1; 2] * [3 4]
Output
ans = 2×1
3
7
ans = 2×2
7 10
15 22
ans = 32
ans = 2×2
3 4
6 8