Question

Solve with GAUSS Elimination in MATLAB 4. 4 1 0 4 5 3 1 2 -9 2 -1 5

0 0
Add a comment Improve this question Transcribed image text
Answer #1

MATLAB code for GAUSS elimination method is :

%Linear equation system 'Ax=r' by Gauss elimination method.
clc
clear all
%=================================================================
disp('Solution of N-equation "[A][X]=[r]"')
n=input ('Enter number of Equations :');
A=input ('Enter Matrix [A]:');
r=input ('Enter Matrix [r]:');
D=A;d=r;
%-----------------------------------------------------------------
%create upper triangular matrix
s=0;
for j=1:n-1
if A(j,j)==0
k=j;
for k=k+1:n
if A(k,j)==0
continue
end
break
end
B=A(j,:); C=r(j);
A(j,:)=A(k,:); r(j)=r(k);
A(k,:)=B; r(k)=C;
end
for i=1+s:n-1
L=A(i+1,j)/A(j,j);
A(i+1,:)=A(i+1,:)-L*A(j,:);
r(i+1)=r(i+1)-L*r(j);
end
s=s+1;
end
%-----------------------------------------------------------------
%Solution of equations
x(n)=r(n)/A(n,n);
for i=n-1:-1:1
sum=0;
for j=i+1:n
sum=sum+A(i,j)*x(j);
end
x(i)=(1/A(i,i))*(r(i)-sum);
end
%Output
disp('@----------------------------------------------------------@')
disp('Output [B][x]=[b]')
disp('Upper triangular Matrix [B] =');disp(A)
disp('Matrix [b] =');disp(r)
disp('solution of linear equations :');disp(x')

Command window output is :

Solution of N-equation "[A][X]=[r]"
Enter number of Equations :3
Enter Matrix [A]:[4 1 0;5 -3 1;-9 2 -1]
Enter Matrix [r]:[4;2;5]
@----------------------------------------------------------@
Output [B][x]=[b]
Upper triangular Matrix [B] =
4.0000 1.0000 0
0 -4.2500 1.0000
0 0 0

Matrix [b] =
4
-3
11

solution of linear equations :
NaN
Inf
Inf

Conclusion from result :

The equation posses the no solutions since RANK(A)<RANK(A|b)....(Inconsistent system of equations)

plzzz rate it.... if you have any doubts comment on the answer.....

Add a comment
Know the answer?
Add Answer to:
Solve with GAUSS Elimination in MATLAB 4. 4 1 0 4 5 3 1 2 -9...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT