find rref for augmented matrix in matlab

The function rref in MATLAB can be used to find the reduced row echelon form (rref) of an augmented matrix. The syntax for using the function is as follows:

main.m
>> A_augmented = [A, b];
>> rref_A_augmented = rref(A_augmented);
66 chars
3 lines

where A is the coefficient matrix, b is the right-hand side vector, and A_augmented is the augmented matrix formed by concatenating A and b. The output rref_A_augmented is the reduced row echelon form of A_augmented.

Here's an example:

main.m
>> A = [2, 3, 4; 1, 2, 1; 4, 5, 7];
>> b = [4; 2; 7];
>> A_augmented = [A, b];
>> rref_A_augmented = rref(A_augmented)

rref_A_augmented =

    1.0000         0   -0.8462   -1.5385
         0    1.0000    0.3077    1.0000
         0         0         0         0
263 chars
11 lines

In this example, we first form the augmented matrix A_augmented by concatenating A and b. We then apply the rref function to A_augmented and store the result in rref_A_augmented. The resulting matrix is the reduced row echelon form of A_augmented.

gistlibby LogSnag