Please Explain Gauss elimination Matlab Code

2 visualizaciones (últimos 30 días)
Student
Student el 18 de Oct. de 2015
Editada: Walter Roberson el 18 de Oct. de 2015
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

Respuestas (0)

Categorías

Más información sobre Numerical Integration and Differential Equations en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by