Please Explain Gauss elimination Matlab Code

Hi I am new to Matlab below is the code provided by my university and I am finding difficulties in understanding the code at the highlighted areas I am well aware of Gauss elimination process and I am good at math manually but I am facing lot of problem in understanding the code for Gauss elimination I got some basic knowledge on matlab of how to save function and execute the program successfully
Can anyone explain the code from line no 5 I got stuck up in understanding the logic in the program sequence
Thanks in advance
function [x]=gauss1(A,b)
[n,m] = size(A);
if n~=m; error('A is not a square matrix'); else
% Forward elimination
for k = 1:n-1,
for i = k+1:n,
if A(k,k)==0, error('Null diagonal element'); end
r = A(i,k)/A(k,k);
b(i) = b(i)-r*b(k);
for j = k+1:n,
A(i,j) = A(i,j)-r*A(k,j);
end
end
end

Answers (0)

Categories

Find more on Numerical Integration and Differential Equations in Help Center and File Exchange

Asked:

on 18 Oct 2015

Edited:

on 18 Oct 2015

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!