5.1 Arithmetic matrix operations The basic arithmetic operations on matrices(and of course scalars which are special cases of matrices)are + addition subtraction multiplication right division left division exponentiation(power) conjugate transpose An error message occurs if the sizes of matrices are incompatible for the operation. Division is defined as follows: The solution to A*r=b is x A\b and the solution to x*A= b is x= b/A provided A is invertible and all the matrices are compatible Addition and subtraction involve element-by-element arithmetic operations; matrix mu tiplication and division do not. However, matlaB provides for element-by-element opera tions as well by prepending a. before the operator as follows multiplication right division left division exponentiation (power transpose(unconjugated) The difference between matrix multiplication and element-by-element multiplication is seen in the following example >>A=[12;34] 2 4 >>B=A*A 5.2 Relational operations The following relational operations are defined
5.1 Arithmetic matrix operations The basic arithmetic operations on matrices (and of course scalars which are special cases of matrices) are: + addition - subtraction * multiplication / right division \ left division ^ exponentiation (power) ’ conjugate transpose An error message occurs if the sizes of matrices are incompatible for the operation. Division is defined as follows: The solution to A ∗ x = b is x = A\b and the solution to x ∗ A = b is x = b/A provided A is invertible and all the matrices are compatible. Addition and subtraction involve element-by-element arithmetic operations; matrix multiplication and division do not. However, MATLAB provides for element-by-element operations as well by prepending a ‘.’ before the operator as follows: .* multiplication ./ right division .\ left division .^ exponentiation (power) .’ transpose (unconjugated) The difference between matrix multiplication and element-by-element multiplication is seen in the following example >>A = [1 2; 3 4] A = 1 2 3 4 >>B=A*A B = 7 10 15 22 >>C=A.*A C = 1 4 9 16 5.2 Relational operations The following relational operations are defined: 6
less than < less than or equal to greater than >= greater than or equal to not equal t These are element-be-element operations which return a matrix of ones(1= true)and zeros (0= false). Be careful of the distinction between=and==' 5.3 Flow control operations MATLAB contains the usual set of flow control structures, e.g., for, while, and if, plus the logical operators, e. g, &(and), I(or), and-(not) 5.4 Math functions MATLAB comes with a large number of built-in functions that operate on matrices on an element-by element basis. These include Sn coS tan Inverse sine atan inverse tangent exp exponential g natural logarithm log10 common logarith sart square root absolute value SIgn signum 6 MATLAB Files There are several types of MATLAB files including files that contain scripts of MATLAB commands, files that define user-created MATLAB functions that act just like built-in Mat LAB functions, files that include numerical results or plots
< less than <= less than or equal to > greater than >= greater than or equal to == equal to ~= not equal to These are element-be-element operations which return a matrix of ones (1 = true) and zeros (0 = false). Be careful of the distinction between ‘=’ and ‘==’. 5.3 Flow control operations MATLAB contains the usual set of flow control structures, e.g., for, while, and if, plus the logical operators, e.g., & (and), | (or), and ~ (not). 5.4 Math functions MATLAB comes with a large number of built-in functions that operate on matrices on an element-by element basis. These include: sin sine cos cosine tan tangent asin inverse sine acos inverse cosine atan inverse tangent exp exponential log natural logarithm log10 common logarithm sqrt square root abs absolute value sign signum 6 MATLAB Files There are several types of MATLAB files including files that contain scripts of MATLAB commands, files that define user-created MATLAB functions that act just like built-in MATLAB functions, files that include numerical results or plots. 7