Draft for Information Only
Content
MatLab: Scratch Pad &
Arithmetic
Operations
MatLab: Scratch Pad & Arithmetic OperationsMajor 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 OperatorsSince 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:
Matrix Arithmetic Operations+ AdditionThe + 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
+ Unary PlusThe + unary plus operator of the expression +A means returns matrix A. Examples
 SubtractionThe  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
 Unary MinusThe  unary minus operator of the expression A means returns and negates the elements of matrix A. Examples
* Matrix MultiplicationThe * 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
/ Slash or Matrix Right DivisionThe / 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
\ Backslash or Matrix Left DivisionThe \ 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
^ Matrix PowerThe ^ 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
' Matrix Transpose or Complex Conjugate TransposeThe ' 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
Array Arithmetic Operations+ AdditionThe + 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
+ Unary PlusThe + unary plus operator of the expression +A means returns A. Examples
 SubtractionThe  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
 Unary MinusThe  unary minus operator of the expression A means returns and negates the elements of A. Examples
.* Array MultiplicationThe .* 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
./ Array Right DivisionThe ./ 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
.\ Array Left DivisionThe .\ 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
.^ Array PowerThe .^ 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
.' Array TransposeThe .' 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
Arithmetic Operation FunctionsThe function of an arithmetic operator also have its corresponding function call.
Arithmetic ExpressionsAn 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 PrecedenceAn 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
Since parentheses have the highest precedence level, parentheses are used to override the default precedence of all other operations.
©sideway ID: 140400003 Last Updated: 4/8/2014 Revision: 0 Latest Updated Links

Home_{ 5} Business Management HBR_{ 3} Information Recreation Hobbies_{ 8} Culture Chinese_{ 1097} English_{ 339} Reference_{ 79} Computer Hardware_{ 249} Software Application_{ 213} Digitization_{ 32} Latex_{ 52} Manim_{ 205} KB_{ 1} Numeric_{ 19} Programming Web_{ 289} Unicode_{ 504} HTML_{ 66} CSS_{ 65} SVG_{ 46} ASP.NET_{ 270} OS_{ 429} DeskTop_{ 7} Python_{ 72} Knowledge Mathematics Formulas_{ 8} Set_{ 1} Logic_{ 1} Algebra_{ 84} Number Theory_{ 206} Trigonometry_{ 31} Geometry_{ 34} Coordinate Geometry_{ 2} Calculus_{ 67} Complex Analysis_{ 21} Engineering Tables_{ 8} Mechanical Mechanics_{ 1} Rigid Bodies Statics_{ 92} Dynamics_{ 37} Fluid_{ 5} Fluid Kinematics_{ 5} Control Process Control_{ 1} Acoustics_{ 19} FiniteElement_{ 2} Natural Sciences Matter_{ 1} Electric_{ 27} Biology_{ 1} Geography_{ 1} 
Copyright © 20002024 Sideway . All rights reserved Disclaimers last modified on 06 September 2019