Matlab矩阵幂运算

Matlab帮助文档

help mpower

 ^   Matrix power.
    Z = X^y is X to the y power if y is a scalar and X is square. If y
    is an integer greater than one, the power is computed by repeated
    squaring. For other values of y the calculation involves
    eigenvalues and eigenvectors.
 
    Z = x^Y is x to the Y power if Y is a square matrix and x is a scalar.
    Computed using eigenvalues and eigenvectors.
 
    Z = X^Y, where both X and Y are matrices, is an error.
 
    C = MPOWER(A,B) is called for the syntax 'A ^ B' when A or B is an
    object.
 
    See also power.
矩阵幂运算
Z = X^y,这里X是矩阵y是标量。如果y是一个比0大的整数,幂运算表示相同矩阵乘积,如果y取其他值,需要计算特征值和特征向量
Z = x^Y,这里Y是矩阵x是标量。使用特征值和特征向量进行计算
Z = X^Y,X和Y都是矩阵时,不能运算
简单的说,矩阵幂运算只能计算两种情况,矩阵的数次幂和数的矩阵次幂。前一种高等数学高等代数里面定义过了,后一种是Matlab自己定义的

这里着重介绍一下,第二种情况,数字的矩阵次幂,Z = x^Y,这种情况先对Y对角化,然后对对角线的每个元素做幂运算,然后通过逆变换变换回来
一般矩阵对角化过程:

A=[3 2 -1;-2 -2 2;3 6 -1]
[V,D]=eig(A)  %V是特征向量,每一列是一个特征向量,D是对角阵,对角元素是对应的特征向量
T=inv(V)*A*V   %inv(V)*A*V=D,所以V是变换使用的变换矩阵
执行结果

A =

     3     2    -1
    -2    -2     2
     3     6    -1


V =

    0.8890    0.2673    0.1654
   -0.2540   -0.5345    0.3737
    0.3810    0.8018    0.9127


D =

     2     0     0
     0    -4     0
     0     0     2


T =

    2.0000         0         0
    0.0000   -4.0000    0.0000
   -0.0000   -0.0000    2.0000
数字的矩阵次幂计算过程

A=[3 2 -1;-2 -2 2;3 6 -1]
S=2^A
[V,D]=eig(A)
A2=2^D       %对角线分别做幂运算
S2=V*A2*inv(V)  %做逆变换得到结果
执行结果

A =

     3     2    -1
    -2    -2     2
     3     6    -1


S =

    4.6563    1.3125   -0.6562
   -1.3125    1.3750    1.3125
    1.9687    3.9375    2.0313


V =

    0.8890    0.2673    0.1654
   -0.2540   -0.5345    0.3737
    0.3810    0.8018    0.9127


D =

     2     0     0
     0    -4     0
     0     0     2


A2 =

    4.0000         0         0
         0    0.0625         0
         0         0    4.0000


S2 =

    4.6563    1.3125   -0.6562
   -1.3125    1.3750    1.3125
    1.9687    3.9375    2.0313





你可能感兴趣的:(matlab,编程)