[Mabadiliko] How to use MATLAB to analyse wastewater treatment systems by Gauss elimination?

Thursday, October 03, 2013
Dear colleagues
 
I tried to use MATLAB to solve a numerical method problem on waste water treatment system analysis (membrane reactor) by "Gauss elimination" with the below m-file.
 
Unfortunately, I received an error message as below:-
 
Error in ==> Gauss at 10
ab = [a,b];
 
The matrix I am working on is 11 x 11, its determinant is zero.
 
Matrix
 
a = [1 0 -1 0 -1 0 0 0 0 0 0; 0 1 0 -1 0 -1 0 0 0 0 0; 0 0 1 0 0 0 -1 0 0 0 -1; 0 0 0 1 0 0 0 -1 0 0 0; 0 0 0 0 1 0 1 0 -1 0 0; 0 0 0 0 0 1 0 1 0 -1 0; 0.9 -0.1 0 0 0 0 0 0 0 0 0; 0 0 0 0 0 0 0 0 0.97 -0.03 0; 0 0 -1 0 0 0 1 0 0 0 0; 0 0 0.9 -0.1 0 0 0 0 0 0 0; 1 1 0 0 0 0 0 0 0 0 0]
 
b = [0 0 0 0 0 0 0 0 0 0 1000]
 
Note: use "copy and paste" when entering matrix "a" in MATLAB. I had to put this way to save your time. 
 
If you are familiar with MATLAB, could you please copy this m-file and try to run on your PC, then let me know what is the cause for this problem?
 
The m-file is
 

function x = Gauss(a,b)

% The function solve a system of linear equations [a][x]=[b] using the Gauss

% elimination method.

% Input variables:

% a The matrix of coefficients.

% b A column vector of constants.

% Output variable:

% x A colum vector with the solution.

ab = [a,b];

[R, C] = size(ab);

for j = 1:R-1

for i = j+1:R

ab(i,j:C) = ab(i,j:C)-ab(i,j)/ab(j,j)*ab(j,j:C);

end

end

x = zeros(R,1);

x(R) = ab(R,C)/ab(R,R);

for i = R-1:-1:1

x(i)=(ab(i,C)-ab(i,i+1:R)*x(i+1:R))/ab(i,i);

end

--
Unapokea Email hizi kwa sababu umejiunga na Jukwaa la 'Mabadiliko'.
Kuchangia mada tuma kwenye Email hii: mabadilikotanzania@googlegroups.com
 
Kujiondoa Tuma Email kwenda; mabadilikotanzania+unsubscribe@googlegroups.com
Utapokea Email ya kudhibitisha kujiondoa kwako.
 
TEMBELEA Facebook yetu:
http://www.facebook.com/MabadilikoForums?ref=hl
 
For more options, visit this group at:
http://groups.google.com/group/mabadilikotanzania?hl=en?hl=en
---
You received this message because you are subscribed to the Google Groups "Mabadiliko Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mabadilikotanzania+unsubscribe@googlegroups.com.
To post to this group, send email to mabadilikotanzania@googlegroups.com.
Visit this group at http://groups.google.com/group/mabadilikotanzania.
For more options, visit https://groups.google.com/groups/opt_out.

Share this :

Related Posts

0 Comments