Matlab中矩阵的分解

1、常见的分解方法

(1)三角分解(LU分解

(2)正交分解(QR)

(3)特征值分解(eig分解)

(4)奇异值分解(svd)

(5)Chollesky分解

2、三角分解(LU分解

>> A = [1 2 3 4;5 6 7 8;9 10 11 12;13 14 15 16]

A =

     1     2     3     4
     5     6     7     8
     9    10    11    12
    13    14    15    16

>> [l,u] = lu(A)

l =

    0.0769    1.0000         0         0
    0.3846    0.6667   -0.5000    1.0000
    0.6923    0.3333    1.0000         0
    1.0000         0         0         0


u =

   13.0000   14.0000   15.0000   16.0000
         0    0.9231    1.8462    2.7692
         0         0   -0.0000   -0.0000
         0         0         0   -0.0000

>> [l,u,p] = lu(A)

l =

    1.0000         0         0         0
    0.0769    1.0000         0         0
    0.6923    0.3333    1.0000         0
    0.3846    0.6667   -0.5000    1.0000


u =

   13.0000   14.0000   15.0000   16.0000
         0    0.9231    1.8462    2.7692
         0         0   -0.0000   -0.0000
         0         0         0   -0.0000


p =

     0     0     0     1
     1     0     0     0
     0     0     1     0
     0     1     0     0
说明:p是A交换矩阵

3、正交分解(QR)

>>  A = [1 2 3 4;5 6 7 8;9 10 11 12;13 14 15 16]

A =

     1     2     3     4
     5     6     7     8
     9    10    11    12
    13    14    15    16

>> [q,r] = qr(A)

q =

   -0.0602   -0.8345    0.2702   -0.4765
   -0.3010   -0.4576   -0.0051    0.8366
   -0.5417   -0.0808   -0.8003   -0.2439
   -0.7825    0.2961    0.5352   -0.1163


r =

  -16.6132  -18.2986  -19.9841  -21.6695
         0   -1.0768   -2.1535   -3.2303
         0         0    0.0000    0.0000
         0         0         0    0.0000

>> [q,r,e] = qr(A)

q =

   -0.1826   -0.8165    0.5068    0.2078
   -0.3651   -0.4082   -0.8306    0.1006
   -0.5477   -0.0000    0.1409   -0.8247
   -0.7303    0.4082    0.1829    0.5163


r =

  -21.9089  -16.4317  -18.2574  -20.0832
         0    2.4495    1.6330    0.8165
         0         0    0.0000   -0.0000
         0         0         0   -0.0000


e =

     0     1     0     0
     0     0     1     0
     0     0     0     1
     1     0     0     0
说明:e是A交换矩阵
4、 特征值分解(eig分解)

>> A = magic(10)

A =

    92    99     1     8    15    67    74    51    58    40
    98    80     7    14    16    73    55    57    64    41
     4    81    88    20    22    54    56    63    70    47
    85    87    19    21     3    60    62    69    71    28
    86    93    25     2     9    61    68    75    52    34
    17    24    76    83    90    42    49    26    33    65
    23     5    82    89    91    48    30    32    39    66
    79     6    13    95    97    29    31    38    45    72
    10    12    94    96    78    35    37    44    46    53
    11    18   100    77    84    36    43    50    27    59

>> [v,d] = eig(A)

v =

  Columns 1 through 5

   0.3162             0.2500            -0.3162             0.3322            -0.4512          
   0.3162             0.2500            -0.3162             0.3725             0.3964          
   0.3162            -0.5000            -0.3162             0.3581            -0.4078          
   0.3162             0.2500            -0.3162             0.2660             0.1077          
   0.3162             0.2500            -0.3162             0.2098             0.1692          
   0.3162            -0.2500             0.3162            -0.3014            -0.4266          
   0.3162            -0.2500             0.3162            -0.2612             0.4211          
   0.3162             0.5000             0.3162            -0.1845            -0.1352          
   0.3162            -0.2500             0.3162            -0.3677             0.1324          
   0.3162            -0.2500             0.3162            -0.4238             0.1939          

  Columns 6 through 10

   0.0336             0.1227             0.4554            -0.3542 - 0.0179i  -0.3542 + 0.0179i
  -0.0586             0.0781             0.1344            -0.4556 + 0.0000i  -0.4556 - 0.0000i
   0.4509             0.2997             0.4554            -0.3542 - 0.0179i  -0.3542 + 0.0179i
  -0.2334             0.2875            -0.0319            -0.0419 + 0.0952i  -0.0419 - 0.0952i
  -0.1674            -0.3274            -0.2572            -0.0177 - 0.1725i  -0.0177 + 0.1725i
   0.3178             0.1407            -0.4554             0.3542 + 0.0179i   0.3542 - 0.0179i
   0.2256             0.0961            -0.1344             0.4556             0.4556          
  -0.7359            -0.6936            -0.4554             0.3542 + 0.0179i   0.3542 - 0.0179i
   0.0508             0.3055             0.0319             0.0419 - 0.0952i   0.0419 + 0.0952i
   0.1168            -0.3094             0.2572             0.0177 + 0.1725i   0.0177 - 0.1725i


d =

   1.0e+02 *

  Columns 1 through 5

   5.0500                  0                  0                  0                  0          
        0             0.7500                  0                  0                  0          
        0                  0            -0.7500                  0                  0          
        0                  0                  0            -0.4255                  0          
        0                  0                  0                  0            -0.2625          
        0                  0                  0                  0                  0          
        0                  0                  0                  0                  0          
        0                  0                  0                  0                  0          
        0                  0                  0                  0                  0          
        0                  0                  0                  0                  0          

  Columns 6 through 10

        0                  0                  0                  0                  0          
        0                  0                  0                  0                  0          
        0                  0                  0                  0                  0          
        0                  0                  0                  0                  0          
        0                  0                  0                  0                  0          
   0.4255                  0                  0                  0                  0          
        0             0.2625                  0                  0                  0          
        0                  0            -0.0000                  0                  0          
        0                  0                  0             0.0000 + 0.0000i        0          
        0                  0                  0                  0             0.0000 - 0.0000i


>> [v,d] = eig(A,'nobalance')

v =

  Columns 1 through 5

   1.0000             0.5000            -1.0000             0.7839            -1.0000          
   1.0000             0.5000            -1.0000             0.8788             0.8785          
   1.0000            -1.0000            -1.0000             0.8449            -0.9038          
   1.0000             0.5000            -1.0000             0.6276             0.2388          
   1.0000             0.5000            -1.0000             0.4951             0.3751          
   1.0000            -0.5000             1.0000            -0.7112            -0.9454          
   1.0000            -0.5000             1.0000            -0.6163             0.9332          
   1.0000             1.0000             1.0000            -0.4353            -0.2995          
   1.0000            -0.5000             1.0000            -0.8676             0.2934          
   1.0000            -0.5000             1.0000            -1.0000             0.4297          

  Columns 6 through 10

   0.0456             0.1769             1.0000            -0.1120 - 0.6408i  -0.1120 + 0.6408i
  -0.0796             0.1126             0.2952            -0.1852 - 0.8148i  -0.1852 + 0.8148i
   0.6127             0.4321             1.0000            -0.1120 - 0.6408i  -0.1120 + 0.6408i
  -0.3172             0.4145            -0.0700            -0.1872 - 0.0362i  -0.1872 + 0.0362i
  -0.2275            -0.4720            -0.5648             0.3013 - 0.1017i   0.3013 + 0.1017i
   0.4318             0.2029            -1.0000             0.1120 + 0.6408i   0.1120 - 0.6408i
   0.3066             0.1386            -0.2952             0.1852 + 0.8148i   0.1852 - 0.8148i
  -1.0000            -1.0000            -1.0000             0.1120 + 0.6408i   0.1120 - 0.6408i
   0.0690             0.4405             0.0700             0.1872 + 0.0362i   0.1872 - 0.0362i
   0.1587            -0.4461             0.5648            -0.3013 + 0.1017i  -0.3013 - 0.1017i


d =

   1.0e+02 *

  Columns 1 through 5

   5.0500                  0                  0                  0                  0          
        0             0.7500                  0                  0                  0          
        0                  0            -0.7500                  0                  0          
        0                  0                  0            -0.4255                  0          
        0                  0                  0                  0            -0.2625          
        0                  0                  0                  0                  0          
        0                  0                  0                  0                  0          
        0                  0                  0                  0                  0          
        0                  0                  0                  0                  0          
        0                  0                  0                  0                  0          

  Columns 6 through 10

        0                  0                  0                  0                  0          
        0                  0                  0                  0                  0          
        0                  0                  0                  0                  0          
        0                  0                  0                  0                  0          
        0                  0                  0                  0                  0          
   0.4255                  0                  0                  0                  0          
        0             0.2625                  0                  0                  0          
        0                  0            -0.0000                  0                  0          
        0                  0                  0             0.0000 + 0.0000i        0          
        0                  0                  0                  0             0.0000 - 0.0000i

5、 Chollesky分解

>> A = [4,-1,1;-1,4.25,2.75;1,2.75,3]

A =

    4.0000   -1.0000    1.0000
   -1.0000    4.2500    2.7500
    1.0000    2.7500    3.0000

>> chol(A)

ans =

    2.0000   -0.5000    0.5000
         0    2.0000    1.5000
         0         0    0.7071



你可能感兴趣的:(matlab,正交分解QR,特征值分解eig分解,Chollesky分解,三角分解LU分解)