MatLab: Scratch Pad & Arithmetic Operations
Major Reference Source: MatLab Verson 7.0
Using MatLab package as a scratch pad interactively is one of the common application of the MatLab package. MatLab commands are entered at the prompt command, >>, of the Command Window through the PC keyboard. Both entered commands and evaluation results are displayed in the Command Window. All new line or lines of commands or instructions after the prompt command will be passed to MatLab for evaluation after pressing the Enter key no matter the position of mouse cursor is at the end of line or lines or not.
Arithmetic Operators
Since all types of data in MatLab are stored in the form of arrays, MatLab provides two different kinds of arithmetic operations, i.e. array operations and matrix operations. MatLab array operations are just ordinary arithmetic operations that supports multidimenstional arrays for processing element by elemt operations. While MatLab matrix operation are ordinary matrix operations that following the rules of linear algebra. Both array operations and matrix operations share the similar symbols of operation, a period characater, "." is used to distinguish the array operations from the matrix operations. However, as the addition and subtraction for both matrix operation and array operation are the same, the period characater, "." is not necessary and the character pairs ".+" and "." are not used. Besides, the 1by1 array, scalar, is also a special type of MatLab array. A 1by1 array, scalar can have array operation with an array of any size also. A 1by1 matrix, scalar can also have martrix operation with a matrix of any size, but limited by the matrix multiplication, the 1by1 matrix, scalar can only be the divisor of the right and left division.
The matrix and array arithmetic includes seven types of operations:
Arithmetic Operators  Matrix Arithmetic Operations  ElementWise Array Arithmetic Operations  

Syntax  Description  Syntax  Description  
Addition +  A+B  Addition  A+B  Addition 
+A  Unary Plus  +A  Unary Plus  
Subtraction   AB  Subtraction  AB  Subtraction 
A  Unary Minus  A  Unary Minus  
Multiplication *  A*B  Matrix Multiplication  A.*B  Array Multiplication 
Right Division /  A/B  Forward Slash or Matrix Right Division  A./B  Array Right Division 
Left Division \  A\B  Backslash or Matrix Left Division  A.\B  Array Left Division 
Power ^  A^B  Matrix Power  A.^B  Array Power 
Transpose '  A'  Matrix Transpose or Complex Conjugate Transpose  A.'  Array Transpose 
Matrix Arithmetic Operations
+ Addition
The + addition operator of the expression A+B means adds matrix B to matrix A. Since only a scalar can be added by or added to a matrix of any size, unless either A or B is a scalar, A and B must have the same size.
Examples

mbyn matrix A + mbyn matrix B

scalar S + matrix A + scalar S
+ Unary Plus
The + unary plus operator of the expression +A means returns matrix A.
Examples

+matrix A
 Subtraction
The  subtraction operator of the expression AB means subtracts matrix B from matrix A. Since only a scalar can be subtracted by or subtracted from a matrix of any size, unless either A or B is a scalar, A and B must have the same size.
Examples

mbyn matrix A  mbyn matrix B

scalar S  mbyn matrix A  scalar S
 Unary Minus
The  unary minus operator of the expression A means returns and negates the elements of matrix A.
Examples

matrix A
* Matrix Multiplication
The * matrix multiplication operator of the expression A*B means to carry out the linear algebraic product of matrix A by matrix B.
Since only a scalar can be multiplicated by or multiplicated to a matrix of any size, two or more dimensions are supported, unless either A or B is a scalar, otherwise the number of columns of matrix A must equal to the number of rows of matrix B.
Examples

mbyn matrix A * nbyo matrix B

scalar S * mbyn matrix A * scalar S
/ Slash or Matrix Right Division
The / slash or matrix right division operator of the expression A/B means to carry out the linear algebraic product of matrix A by the inverse of matrix B, A*inv(B), in a general sense of the solution to the equation xB=A or A/B equals to (B'\A')'
Limited by the linear algebraic product of matrix, only a scalar can divide a matrix of any size, unless B is a scalar, otherwise both matrices A and B must have the same number of columns.
Examples

mbyn matrix A / obyn matrix B

matrix A / scalar S
\ Backslash or Matrix Left Division
The \ backslash or matrix left division operator of the expression A\B means to carry out the linear algebraic product of the inverse of matrix A by matrix B, inv(A)*B, in a general sense of the solution to the equation Ax=B.
Limited by the linear algebraic product of matrix, only a scalar can divide a matrix of any size, unless A is a scalar, otherwise both matrices A and B must have the same number of rows.
Examples

mbyn matrix A \ mbyo matrix B

scalar S \ matrix A
^ Matrix Power
The ^ matrix power operator of the expression A^B means to carry out the matrix A to the power of matrix B. However, one of the matrices A and B must be a scalar and the other matrix must be a square matrix.
If B is a scalar of a positive integer and A is a matrix, the matrix power means repeated matrix multiplication of matrix A by itself of the value of scalar B times. If B is scalar of a negative integer, the matrix power means repeated matrix multiplication of the inverse of matrix A by itself to the absolute value of scalar B times. If B is a scalar not equal to an integer and A is a matrix, the matrix power means the calculation involves eigenvalues and eigenvectors, such that if [V,D]=eig(A), then A^B=V*D.^B/V.
If A is a scalar and B is a matrix, the matrix power also means the calculation involves eigenvalues and eigenvectors, such that if [V,D]=eig(A), then A^B=V*D.^B/V.
Examples

square matrix A ^ scalar S of positive integer

square matrix A ^ scalar S of negative integer

square matrix A ^ scalar S of noninteger

scalar S ^ square matrix A
' Matrix Transpose or Complex Conjugate Transpose
The ' matrix transpose or complex conjugate transpose operator of the expression A' means to carry out the linear algebraic transpose of matrix A. If matrix A is a complex matrix, the matrix transpose operator means to carry out the complex conjugate transpose.
Examples

mbyn matrix A'

mbyn complex matrix A'
Array Arithmetic Operations
+ Addition
The + addition operator of the expression A+B means adds B to A. Since only a scalar can be added to a matrix of any size, unless either A or B is a scalar, A and B must have the same size.
Examples

mbynbyo array A + mbynbyo array B

scalar S + mbyn array A + scalar S
+ Unary Plus
The + unary plus operator of the expression +A means returns A.
Examples

+array A
 Subtraction
The  subtraction operator of the expression AB means subtracts B from A. Since only a scalar can be subtracted by or subtracted from a matrix of any size, unless either A or B is a scalar, A and B must have the same size.
Examples

mbynbyo array A  mbynbyo array B

scalar S  mbynbyo array A  scalar S
 Unary Minus
The  unary minus operator of the expression A means returns and negates the elements of A.
Examples

array A
.* Array Multiplication
The .* array multiplication operator of the expression A.*B means to carry out the element by element product of array A by array B.
Since only a scalar can be multiplicated by or multiplicated to a matrix of any size, unless either A or B is a scalar, otherwise the size of arrays A and B must be equal. Arrays with two or more dimensions are supported.
Examples

mbynbyo array A .* mbynbyo array B

scalar S .* mbynbyo array A .* scalar S
./ Array Right Division
The ./ array right division operator of the expression A./B means to carry out the element by element division of array A by array B.
Since only a scalar can be divided by or divide an array of any size, unless either A or B is a scalar, otherwise the size of arrays A and B must be equal. Arrays with two or more dimensions are supported.
Examples

mbynbyo array A ./ mbynbyo array B

scalar S ./ mbynbyo array A ./ scalar S
.\ Array Left Division
The .\ array left division operator of the expression A.\B means to carry out the element by element division of array B by array A.
Since only a scalar can be divided by or divide an array of any size, unless either A or B is a scalar, otherwise the size of arrays A and B must be equal. Arrays with two or more dimensions are supported.
Examples

mbynbyo array A .\ mbynbyo array B

scalar S .\ mbynbyo array A .\ scalar S
.^ Array Power
The .^ array power operator of the expression A.^B means to carry out the element by element calculation of the element of array A to the corresponding element of array B.
Since only a scalar can be carried out the element by element operation to an array of any size, unless either A or B is a scalar, otherwise the size of arrays A and B must be equal. Arrays with two or more dimensions are supported.
Examples

mbynbyo array A .^ mbynbyo array B

scalar S .^ mbynbyo array A .^ scalar S
.' Array Transpose
The .' array transpose of the expression A.' means to carry out the two dimensional array transpose of array A for both real and complex array and no complex conjugation is involved. Only one or two dimensional arrays are supported
Examples

mbyn array A.'

mbyn complex array A.'
Arithmetic Operation Functions
The function of an arithmetic operator also have its corresponding function call.
Operation  Description  Function Form 

A+B  Binary Addition  plus(A, B) 
+A  Unary Plus  uplus(A) 
AB  Binary Subtraction  minus(A, B) 
A  Unary Minus  uminus(A) 
A*B  Matrix Multiplication  mtimes(A, B) 
A/B  Forward Slash or Matrix Right Division  mrdivide(A, B) 
A\B  Backslash or Matrix Left Division  mldivide(A, B) 
A^B  Matrix Power  mpower(A, B) 
A'  Matrix Transpose or Complex Conjugate Transpose  ctranspose(A) 
A.*B  Array Multiplication  times(A, B) 
A./B  Array Right Division  rdivide(A, B) 
A.\B  Array Left Division  ldivide(A, B) 
A.^B  Array Power  power(A, B) 
A.'  Array Transpose  transpose(A) 
Arithmetic Expressions
An arithmetic expression is an expression used to represents a numeric value. Arithmetic expressions are built up from numbers, arithmetic operators and parenthese, etc. following some predefined rules and operator precedence.
Operator Precedence
An expression is usually formed from a combination of arithmetic, relational, and logical operators. Arithmetic operators are the most common operators used for performing arithmetic calculation on numbers. MatLab always evaluates expressions from left to right, however the order of operators to be evaluated by MatLab within an expression are determined by the precedence levels of operators. The following operator with a higher precedence level will override the rule of from left to right evaluation. While the operator will be evaluated immediately if the following operator has the same or lower precedence level. The precedence rules for MatLab operators are
Precedence Level  Operators 

1  Parentheses () 
2  Transpose .' ; Power .^ ; Complex conjugate transpose ' ; Matrix power ^ 
3  Unary plus + ; Unary minus  ; Logical negation ~ 
4  Multiplication .* ; Right division ./ ; Left division .\ ; Matrix multiplication * ; Matix right division / ; Matrix left division 
5  Addition + ; Subtraction  
6  Colon operator : 
7  Less than < ; less than or equal to <= ; greater than > ; greater than or equal to >= ; equal to == ; not equal to ~= 
8  Elementwise AND & 
9  Elementwise OR  
10  Shortcircuit AND && 
11  Shortcircuit OR  
Since parentheses have the highest precedence level, parentheses are used to override the default precedence of all other operations.