Create augumanted matrix (A) form the euqation , then use following code :
function A = row_echelon(A)
A(j,:) = A(j,:)/A(j,j);
for i = j+1:m
A(i,:)= A(i,:)- A(j,:)*A(i,j);
Note : This code does not work when A(j,j)=0, So try to madify logic in this code according to your requirements.