-
-
Save TRex22/8d9ee813575d0497fa55 to your computer and use it in GitHub Desktop.
Gauss Jordan
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%Guassian_Elimination with jordan method | |
%This is my code Jason Chalom 711985 | |
%[r, c] = size(A); | |
%A = [2 -1 2 1; 1 1 2 1; 2 1 5 3]; | |
% a has both a matrix and b vector | |
function [output] = Guassian_Elimination_Jordan (a, b) | |
%do gauss first | |
a= horzcat(a,b); | |
[r,c] = size(a); | |
for j = 1:r-1 | |
for i = j+1:r | |
a(i,:) = a(i,:) - a(i,j)/a(j,j)*a(j,:); | |
end | |
end | |
%jordan | |
for j = r:-1 : r-1 | |
for i = 1 : j-1 | |
a(i,:) = a(i,:) - a(i,j)/a(j,j)*a(j,:); | |
end | |
end | |
%output | |
for i=1:r | |
output(i, :)=a(i,end)./a(i,i); | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment