find rref for matrix a = [1 2 3 4 ; 2 3 4 5 ; 3 4 5 6; 1 2 0 1]; b = [0 0 0 0]'; in matlab

To find the row echelon form (REF) and the reduced row echelon form (RREF) of matrix A in Matlab, we use the built-in functions rref and ref, respectively. Here's how to do it:

main.m
% Define matrix A and vector b
A = [1 2 3 4; 2 3 4 5; 3 4 5 6; 1 2 0 1];
b = [0 0 0 0]';

% Augment A with b
AB = [A b];

% Find the row echelon form of AB
REF = rref(AB);

% Find the reduced row echelon form of AB
RREF = rref(AB);

% Separate RREF into matrix and solution vector
R = RREF(:,1:end-1);
s = RREF(:,end);
319 chars
17 lines

The variable R is the matrix in reduced row echelon form, and s is the solution vector. Since b is zero, the system Ax = b has only the trivial solution x = 0, which is confirmed by s.

gistlibby LogSnag