Friday 4 October 2013

[wanabidii] Re: How to use MATLAB to analyse wastewater treatment systems by Gauss elimination?

Nawashukuru wote mliojitokeza kunisaidia.
 
Kwa faida ya wengine; kosa nililofanya ni kuingiza seti bila kuweka ";" i.e. b = [0 0 0 0 0 0 0 0 0 0 1000] "1 row, 11 columns". Kwakua seti yangu "a" ni ya 11x11 ndiyo maana mahesabu yaligoma.
 
Nilipoweka seti b = [0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 1000],nilipata "11 rows, 1 column". Mahesabu yalikubali kwenye MATILAB japo majibu yalikuwa "NAN".
 
Niliporekebisha namba kwenye seti "a" kulingana na hitaji langu, mahesabu yalikubali.
 
Asanteni sana.


On Thu, Oct 3, 2013 at 9:26 PM, Mwema Felix <mwema.felix@gmail.com> wrote:
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


--
Send Emails to wanabidii@googlegroups.com
 
Kujiondoa Tuma Email kwenda
wanabidii+unsubscribe@googlegroups.com Utapata Email ya kudhibitisha ukishatuma
 
Disclaimer:
Everyone posting to this Forum bears the sole responsibility for any legal consequences of his or her postings, and hence statements and facts must be presented responsibly. Your continued membership signifies that you agree to this disclaimer and pledge to abide by our Rules and Guidelines.
---
You received this message because you are subscribed to the Google Groups "Wanabidii" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wanabidii+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

0 comments:

Post a Comment