Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Experiment 4

Name: Ajitsingh Jagtap Reg. no.: 15BCH0075

Slot: L5+L+6

----------------------------------------------------------------------------------------------------------

Input:
Gauss Elimination method
clc
clear all
a=[52 20 25 4800
30 50 20 5810
18 30 55 5690];
[m,n]=size(a);
for j=1:m-1
for z=2:m
if a(j,j)==0
t=a(j,:);a(j,:)=a(z,:);
end
end
for i=j+1:m
a(i,:)=a(i,:)-a(j,:)*(a(i,j)/a(j,j));
end
end
x=zeros(1,m);
for s=m:-1:1
c=0;
for k=2:m
c=c+a(s,k)*x(k);
end
x(s)=(a(s,n)-c)/a(s,s);
end
disp('Gauss elimination method');
a
x'

Output:
a=

1.0e+003 *
0.0520 0.0200 0.0250 4.8000

0.0000 0.0385 0.0056 3.0408

-0.0000 0 0.0430 2.2040

ans =

40.1163

71.6279

51.2558

You might also like