• Matlab中矩阵运算


    1、矩阵的加法

    >> a = [1,2,3,4;5,6,7,8;9,10,11,12]
    
    a =
    
         1     2     3     4
         5     6     7     8
         9    10    11    12
    
    >> b = [2,4,6,8;10,12,14,16;18,20,22,24]
    
    b =
    
         2     4     6     8
        10    12    14    16
        18    20    22    24
    
    >> a + b
    
    ans =
    
         3     6     9    12
        15    18    21    24
        27    30    33    36

    2、矩阵的减法

    >>  a = [1,2,3,4;5,6,7,8;9,10,11,12]
    
    a =
    
         1     2     3     4
         5     6     7     8
         9    10    11    12
    
    >>  b = [2,4,6,8;10,12,14,16;18,20,22,24]
    
    b =
    
         2     4     6     8
        10    12    14    16
        18    20    22    24
    
    >> a - b
    
    ans =
    
        -1    -2    -3    -4
        -5    -6    -7    -8
        -9   -10   -11   -12

    3、矩阵的乘法

    >>  a = [1,2,3,4;5,6,7,8;9,10,11,12]
    
    a =
    
         1     2     3     4
         5     6     7     8
         9    10    11    12
    
    >>  b = [2,4,6,8;10,12,14,16;18,20,22,24;26,28,30,32]
    
    b =
    
         2     4     6     8
        10    12    14    16
        18    20    22    24
        26    28    30    32
    
    >> a*b
    
    ans =
    
       180   200   220   240
       404   456   508   560
       628   712   796   880

    4、矩阵的除法

    >> A=[2 1 -3;3 -2 2;5 -3 -1]
    
    A =
    
         2     1    -3
         3    -2     2
         5    -3    -1
    
    >> B=[5;5;16]
    
    B =
    
         5
         5
        16
    
    >> X=AB
    
    X =
    
         1
        -3
        -2

    5、矩阵的乘方

    >> C = [1,2,3;4,5,6;7,8,9]
    
    C =
    
         1     2     3
         4     5     6
         7     8     9
    
    >> 2^C
    
    ans =
    
       1.0e+04 *
    
        0.7962    0.9782    1.1603
        1.8029    2.2154    2.6276
        2.8097    3.4523    4.0950

    6、矩阵的开方

    >>  C = [1,2,3;4,5,6;7,8,9]
    
    C =
    
         1     2     3
         4     5     6
         7     8     9
    
    >> A = sqrt(C)
    
    A =
    
        1.0000    1.4142    1.7321
        2.0000    2.2361    2.4495
        2.6458    2.8284    3.0000
    >>  C = [1,2,3;4,5,6;7,8,9]
    
    
    C =
    
    
         1     2     3
         4     5     6
         7     8     9
    
    
    >>  A = sqrtm(C)
    
    
    A =
    
    
       0.4498 + 0.7623i   0.5526 + 0.2068i   0.6555 - 0.3487i
       1.0185 + 0.0842i   1.2515 + 0.0228i   1.4844 - 0.0385i
       1.5873 - 0.5940i   1.9503 - 0.1611i   2.3134 + 0.2717i
    

    7、矩阵的点运算

    >> A = [1,2,3;4,5,6;7,8,9]
    
    A =
    
         1     2     3
         4     5     6
         7     8     9
    
    >> B = A
    
    B =
    
         1     2     3
         4     5     6
         7     8     9
    
    >> A.*B
    
    ans =
    
         1     4     9
        16    25    36
        49    64    81
    
    >> A./B
    
    ans =
    
         1     1     1
         1     1     1
         1     1     1


  • 相关阅读:
    如何快速修改替换对象中的某个属性?
    element组件 MessageBox不能显示确认和取消按钮,记录正确使用方法!
    记录一下vue transition 过渡各状态()
    记录一下vue slot
    vue路由传参query和params的区别(详解!)
    一段话让你理解vuex的工作模式!
    vue+axios访问本地json数据踩坑点
    怎么构建vue-cli项目
    IO模型
    epoll真正实现高并发服务器
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13315650.html
Copyright © 2020-2023  润新知