MATLAB Function Reference Previous page   Next Page
mtimes

Matrix multiplication

Syntax

Description

C = A*B is the linear algebraic product of the matrices A and B. If A is an m-by-p and B is a p-by-n matrix, the i,j entry of C is defined by

The product C is an m-by-n matrix. For nonscalar A and B, the number of columns of A must equal the number of rows of B. You can multiply a scalar by a matrix of any size.

The preceding definition says that C(i,j) is the inner product of the ith row of A with the jth column of B. You can write this definition using the MATLAB colon operator as

where A(i,:) is the ith row of A and B(:,j) is the jth row of B.

Examples

Example 1

If A is a row vector and B is a column vector with the same number of elements as A, A*B is simply the inner product of A and B. For example,

Example 2

The product of A and B is

Note that the second row of A is

while the third column of B is

The inner product of A(2,:) and B(:,3) is

which is the same as C(2,3).

Algorithm

mtimes uses the following Basic Linear Algebra Subroutines (BLAS):

For inputs of type single, mtimes using corresponding routines that begin with "S" instead of "D".

See Also

Arithmetic operators


Previous page  msgbox mu2lin Next page

© 1994-2005 The MathWorks, Inc.