Documentation Center

  • Trial Software
  • Product Updates

Arithmetic Operations

Perform arithmetic operations on symbols

Syntax

A+B
A-B
A*B
A.*B
A\B
A.\B
B/A
A./B
A^B
A.^B
A'
A.'

Description

+

Matrix addition. A+B adds A and B. A and B must have the same dimensions, unless one is scalar.

-

Matrix subtraction. A-B subtracts B from A. A and B must have the same dimensions, unless one is scalar.

*

Matrix multiplication. A*B is the linear algebraic product of A and B. The number of columns of A must equal the number of rows of B, unless one is a scalar.

.*

Array multiplication. A.*B is the entry-by-entry product of A and B. A and B must have the same dimensions, unless one is scalar.

\

Matrix left division. A\B solves the symbolic linear equations A*X=B for X. Note that A\B is roughly equivalent to inv(A)*B. Warning messages are produced if X does not exist or is not unique. Rectangular matrices A are allowed, but the equations must be consistent; a least squares solution is not computed.

.\

Array left division. A.\B is the matrix with entries B(i,j)/A(i,j). A and B must have the same dimensions, unless one is scalar.

/

Matrix right division. B/A solves the symbolic linear equation X*A=B for X. Note that B/A is the same as (A.'\B.').'. Warning messages are produced if X does not exist or is not unique. Rectangular matrices A are allowed, but the equations must be consistent; a least squares solution is not computed.

./

Array right division. A./B is the matrix with entries A(i,j)/B(i,j). A and B must have the same dimensions, unless one is scalar.

^

Matrix power. A^B raises the square matrix A to the integer power B. If A is a scalar and B is a square matrix, A^B raises A to the matrix power B, using eigenvalues and eigenvectors. A^B, where A and B are both matrices, is an error.

.^

Array power. A.^B is the matrix with entries A(i,j)^B(i,j). A and B must have the same dimensions, unless one is scalar.

'

Matrix Hermitian transpose. If A is complex, A' is the complex conjugate transpose.

.'

Array transpose. A.' is the real transpose of A. A.' does not conjugate complex entries.

Examples

The following statements

syms a b c d
A = [a b; c d];
A*A/A
A*A-A^2

return

[ a, b]
[ c, d]

[ 0, 0]
[ 0, 0]

The following statements

syms b1 b2
A = sym('a%d%d', [2 2]);
B = [b1 b2];
X = B/A;
x1 = X(1)
x2 = X(2)

return

x1 =
-(a21*b2 - a22*b1)/(a11*a22 - a12*a21)
 
x2 =
(a11*b2 - a12*b1)/(a11*a22 - a12*a21)

See Also

|

Was this topic helpful?