Algoritma Pada MATLAP
A=input('Matriks A=');
[b,k]=size(A);
X=zeros(b,1);
for i=1:b-1
for j=i+1:b
if (A(1,1)==0);
for x=1:b+1
t=A(i,x);
A(i,x)=A(i+1,x);
A(i+1,x)=t;
end
else
p=A(j,i)/A(i,i);
for h=i:b+1
A(j,h)=A(j,h)-p*A(i,h);
A(j,i)=0;
if (abs(A(i,i))==0)
break
end
end
end
A
end
end
X(b)=A(b,b+1)/A(b,b);
for v=b-1:-1:1
S=0;
for m=v+1:b
S=S+A(v,m)*X(m);
X(v)=(A(v,m+1)-S)/A(v,v);
end
end
Tidak ada komentar:
Posting Komentar