Applied Linear Algebra in Geoscience Using MATLAB (Mathematical Operations with Arrays)
Contents Getting Started Matrices Creating Arrays Linear equations Mathematical Operations with Arrays Using Script Files and Managing Data Two-Dimensional Plots Determinants Eigenvalues and eigenvectors Orthogonal vectors and matrices Vector and matrix norms Programming in MATLAB Gaussian elimination and the LU User-Defined Functions and Function Files dec. Polynomials, Curve Fitting, and Interpolation Linear system applications Gram-Schmidt decomposition Applications in Numerical Analysis The singular value decomposition Three-Dimensional Plots Least-squares problems Symbolic Math Implementing the QR factorization TheLinear algebraic problem Applied Algebraeigenvalue in Geoscience Using MATLAB
Addition and Subtraction The operations + and can be used to add (subtract) arrays of identical size and to add (subtract) a scalar to an array.
Array Multiplication The multiplication operation * is executed by MATLAB according to the rules of linear algebra. This means that if A and B are two matrices, the operation A*B can be carried out only if the number of columns in matrix A is equal to the number of rows in matrix B The power operation can be executed only with a square matrix The multiplication of a row vector by a column vector gives a scalar MATLAB also has a built-in function, dot(a,b)
Array Multiplication Linear algebra rules of array multiplication provide a convenient way for writing a system of linear equations. EX.1 the system of three equations with three unknowns
Array Division Inverse of a matrix: The matrix B is the inverse of the matrix A if, when the two matrices are multiplied, the product is the identity matrix. Both matrices must be square and the multiplication order can be The inverse of a matrix A is typically written as A-1. In MATLAB the inverse of a matrix can be obtained either by raising A to the power of 1, or with the inv(a) function. Not every matrix has an inverse. A matrix has an inverse only if it is square and its determinant is not equal to zero. det(a)
Array Division MATLAB has two types of array division, right division and left division. Left division, \ : Left division is used to solve the matrix equation AX = B. In this equation X and B are column vectors. So the solution of AX =B is: In MATLAB Right division, / : The right division is used to solve the matrix equation XC = D. In this equation X and D are row vectors. The solution In MATLAB
Array Division EX.1 Use matrix operations to solve the following system of linear equations.
Element-By-Element Operation The regular symbols for multiplication and division (*and/) The mathematical operations follow the rules of linear algebra Many situations that require element-byelement operations. Element-by-element calculations are very useful for calculating the value of a function at many values of its argument.
Built in Fun. For Analyzing Array
Random Numbers MATLAB has three commands rand, randn, and randi that can be used to assign random numbers to variables.
Example EX.2 The coefficient of friction,, can be determined in an experiment by measuring the force F required to move a mass m. When F is measured and m is known, the coefficient of friction can be calculated by: Results from measuring F in six tests are given in the table below. Determine the coefficient of friction in each test, and the average from all tests.