C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
MATLAB rrefReduced Row Echelon Form (rref) takes the Gauss-Jordan elimination method one step further by operating scaling EROs on all rows so that the aii coefficients on the diagonal all become ones. ![]() Reduced Row Echelon Form take this one step further to result in all 1's rather than the a', so that the column of b's is the solution: ![]() MATLAB has built-in function to do this, known as rref. For example, for the preceding examples: >> a = [1 3 0; 2 1 3; 4 2 3]; >> b = [1 6 3]'; >> ab = [a b]; >> rref(ab) ans = 1 0 0 ?2 0 1 0 1 0 0 1 3 The solutions are found from the last column, so x1 = -2, x2 = 1, and x3 = 3. To get this in the column vector in MATLAB: ![]() Finding Matrix Inverse by reducing an Augmented MatrixFor the system of equations larger than a 2x2 system, one method of finding inverse of a matrix A mathematically contains augmenting the matrix with an identity matrix of a similar size and then reducing it. The algorithm is:
For example, in MATLAB we can starts with a matrix, augmented it with an identity matrix, and then use the rref functions to reduce it. >> a = [1 3 0; 2 1 3; 4 2 3]; >> rref([a eye(size(a))]) ans = 1.0000 0 0 ?0.2000 ?0.6000 0.6000 0 1.0000 0 0.4000 0.2000 ?0.2000 0 0 1.0000 0 0.6667 ?0.3333 In MATLAB, the inv functions can be used to check the result. >> inv(a) ans = ?0.2000 ?0.6000 0.6000 0.4000 0.2000 ?0.2000 0 0.6667 ?0.3333
Next TopicEigenvalues and Eigenvectors
|