clc
clear
A = [1 2 3 4 5;2 -3 -1 1 0;-1 3 1 3 1;2 2 -1 4 1]

[m,n] = size(A)

for i = 1:m
  for j = i+1:m
    A(j,:) = A(j,:)-(A(j,i)/A(i,i))*A(i,:)
  end
end

A 