gauss jordan elimination methodun matlab kodu da ;
% Gauss-Jordan Elimination Generalized Form
clear;
clc;
A = [1 -1 1 5;
-1 1 2 7;
2 1 -1 4];
2
[m,n] = size(A);
% All row operations
% Downwards
for i=1:m
A(i,:) = A(i,:)/A(i,i);
for j=(i+1):m
A(j,:) = A(j,:)+(-1)*A(j,i)*A(i,:);
end
end
%Upwards
for i=m:-1:1
for j=(i-1):-1:1
A(j,:) = A(j,:) + (-1)*A(j,i)*A(i,:);
end
end
%Finding the values
x = []; % Solution vector
for i=1:m
x(i) = A(i,n);
end