A = 4X4 Matrix
x = 4X1 Matrix
b = 4X1 Matrix
function x=gauss44(A,b)
m1=A(2,1)/A(1,1);
m2=A(3,1)/A(1,1);
m3=A(4,1)/A(1,1);
A(2,:)=A(2,:)-m1*A(1,:);
A(3,:)=A(3,:)-m2*A(1,:);
A(4,:)=A(4,:)-m3*A(1,:);
b(2,1)=b(2,1)-m1*b(1,1);
b(3,1)=b(3,1)-m2*b(1,1);
b(4,1)=b(4,1)-m3*b(1,1);
m4=A(3,2)/A(2,2);
m5=A(4,2)/A(2,2);
A(3,:)=A(3,:)-m4*A(2,:);
A(4,:)=A(4,:)-m5*A(2,:);
b(3,1)=b(3,1)-m4*b(2,1);
b(4,1)=b(4,1)-m5*b(2,1);
m6=A(4,3)/A(3,3);
A(4,:)=A(4,:)-m6*A(3,:);
b(4,1)=b(4,1)-m6*b(3,1);
x(4,1)=b(4,1)/A(4,4);
x(3,1)=(b(3,1)-A(3,4)*x(4,1))/A(3,3);
x(2,1)=(b(2,1)-A(2,3)*x(3,1)-A(2,4)*x(4,1))/A(2,2);
x(1,1)=(b(1,1)-A(1,2)*x(2,1)-A(1,3)*x(3,1)-A(1,4)*x(4,1))/A(1,1);
반응형
'이것저것 배운것 > 수업내용 - MATLAB' 카테고리의 다른 글
Gauss_Jordan 소거법 (0) | 2014.11.11 |
---|---|
Fr_bin2dec / Fr_dec2bin (0) | 2014.11.04 |
Gauss (0) | 2014.11.04 |
Test Gauss55 (0) | 2014.11.04 |
Gauss33 (0) | 2014.11.04 |