首页 > 其他 > 详细

高斯消元法求矩阵的行列式

时间:2016-11-20 15:55:51      阅读:754      评论:0      收藏:0      [点我收藏+]
A=[1,-1,1,-4;5,-4,3,12;2,1,1,11;2,-1,7,-1]
Adet=1
%开始消元过程
for k=1:(length(A))
   a=A(k,k)
   Adet = Adet.*a
   for i=1:(length(A))
      A(k,i)=A(k,i)/a
   end
   for i=k+1:(length(A))
      c=-A(i,k)
	  for j=1: (length(A))
		A(i,j)=A(i,j)+c.*A(k,j)
	  end
   end
end
Adet

A =

     1    -1     1    -4
     5    -4     3    12
     2     1     1    11
     2    -1     7    -1


Adet =

     1


a =

     1


Adet =

     1


A =

     1    -1     1    -4
     5    -4     3    12
     2     1     1    11
     2    -1     7    -1


A =

     1    -1     1    -4
     5    -4     3    12
     2     1     1    11
     2    -1     7    -1


A =

     1    -1     1    -4
     5    -4     3    12
     2     1     1    11
     2    -1     7    -1


A =

     1    -1     1    -4
     5    -4     3    12
     2     1     1    11
     2    -1     7    -1


c =

    -5


A =

     1    -1     1    -4
     0    -4     3    12
     2     1     1    11
     2    -1     7    -1


A =

     1    -1     1    -4
     0     1     3    12
     2     1     1    11
     2    -1     7    -1


A =

     1    -1     1    -4
     0     1    -2    12
     2     1     1    11
     2    -1     7    -1


A =

     1    -1     1    -4
     0     1    -2    32
     2     1     1    11
     2    -1     7    -1


c =

    -2


A =

     1    -1     1    -4
     0     1    -2    32
     0     1     1    11
     2    -1     7    -1


A =

     1    -1     1    -4
     0     1    -2    32
     0     3     1    11
     2    -1     7    -1


A =

     1    -1     1    -4
     0     1    -2    32
     0     3    -1    11
     2    -1     7    -1


A =

     1    -1     1    -4
     0     1    -2    32
     0     3    -1    19
     2    -1     7    -1


c =

    -2


A =

     1    -1     1    -4
     0     1    -2    32
     0     3    -1    19
     0    -1     7    -1


A =

     1    -1     1    -4
     0     1    -2    32
     0     3    -1    19
     0     1     7    -1


A =

     1    -1     1    -4
     0     1    -2    32
     0     3    -1    19
     0     1     5    -1


A =

     1    -1     1    -4
     0     1    -2    32
     0     3    -1    19
     0     1     5     7


a =

     1


Adet =

     1


A =

     1    -1     1    -4
     0     1    -2    32
     0     3    -1    19
     0     1     5     7


A =

     1    -1     1    -4
     0     1    -2    32
     0     3    -1    19
     0     1     5     7


A =

     1    -1     1    -4
     0     1    -2    32
     0     3    -1    19
     0     1     5     7


A =

     1    -1     1    -4
     0     1    -2    32
     0     3    -1    19
     0     1     5     7


c =

    -3


A =

     1    -1     1    -4
     0     1    -2    32
     0     3    -1    19
     0     1     5     7


A =

     1    -1     1    -4
     0     1    -2    32
     0     0    -1    19
     0     1     5     7


A =

     1    -1     1    -4
     0     1    -2    32
     0     0     5    19
     0     1     5     7


A =

     1    -1     1    -4
     0     1    -2    32
     0     0     5   -77
     0     1     5     7


c =

    -1


A =

     1    -1     1    -4
     0     1    -2    32
     0     0     5   -77
     0     1     5     7


A =

     1    -1     1    -4
     0     1    -2    32
     0     0     5   -77
     0     0     5     7


A =

     1    -1     1    -4
     0     1    -2    32
     0     0     5   -77
     0     0     7     7


A =

     1    -1     1    -4
     0     1    -2    32
     0     0     5   -77
     0     0     7   -25


a =

     5


Adet =

     5


A =

     1    -1     1    -4
     0     1    -2    32
     0     0     5   -77
     0     0     7   -25


A =

     1    -1     1    -4
     0     1    -2    32
     0     0     5   -77
     0     0     7   -25


A =

     1    -1     1    -4
     0     1    -2    32
     0     0     1   -77
     0     0     7   -25


A =

    1.0000   -1.0000    1.0000   -4.0000
         0    1.0000   -2.0000   32.0000
         0         0    1.0000  -15.4000
         0         0    7.0000  -25.0000


c =

    -7


A =

    1.0000   -1.0000    1.0000   -4.0000
         0    1.0000   -2.0000   32.0000
         0         0    1.0000  -15.4000
         0         0    7.0000  -25.0000


A =

    1.0000   -1.0000    1.0000   -4.0000
         0    1.0000   -2.0000   32.0000
         0         0    1.0000  -15.4000
         0         0    7.0000  -25.0000


A =

    1.0000   -1.0000    1.0000   -4.0000
         0    1.0000   -2.0000   32.0000
         0         0    1.0000  -15.4000
         0         0         0  -25.0000


A =

    1.0000   -1.0000    1.0000   -4.0000
         0    1.0000   -2.0000   32.0000
         0         0    1.0000  -15.4000
         0         0         0   82.8000


a =

   82.8000


Adet =

   414


A =

    1.0000   -1.0000    1.0000   -4.0000
         0    1.0000   -2.0000   32.0000
         0         0    1.0000  -15.4000
         0         0         0   82.8000


A =

    1.0000   -1.0000    1.0000   -4.0000
         0    1.0000   -2.0000   32.0000
         0         0    1.0000  -15.4000
         0         0         0   82.8000


A =

    1.0000   -1.0000    1.0000   -4.0000
         0    1.0000   -2.0000   32.0000
         0         0    1.0000  -15.4000
         0         0         0   82.8000


A =

    1.0000   -1.0000    1.0000   -4.0000
         0    1.0000   -2.0000   32.0000
         0         0    1.0000  -15.4000
         0         0         0    1.0000


Adet =

   414

  

高斯消元法求矩阵的行列式

原文:http://www.cnblogs.com/mubu/p/6082681.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!