matlab-線性代數 矩陣的加、減、乘、除

     matlab : R2018a 64bit
      OS : Windows 10 x64
typesetting : Markdown
       blog : my.oschina.net/zhichengjiu
      gitee : gitee.com/zhichengjiugit

加、減、乘、除(矩陣單元素)

code

clear
clc

a=[1 2 3 4;5 6 7 8;1 2 3 4;6 7 8 9]
 
a(1,1)=a(1,1)+3
a(1,1)=a(1,1)-3
a(1,1)=a(1,1)*3
a(1,1)=a(1,1)/3

result

a =

     1     2     3     4
     5     6     7     8
     1     2     3     4
     6     7     8     9


a =

     4     2     3     4
     5     6     7     8
     1     2     3     4
     6     7     8     9


a =

     1     2     3     4
     5     6     7     8
     1     2     3     4
     6     7     8     9


a =

     3     2     3     4
     5     6     7     8
     1     2     3     4
     6     7     8     9


a =

     1     2     3     4
     5     6     7     8
     1     2     3     4
     6     7     8     9

>>

加、減(矩陣與矩陣或數字)

code

clear
clc

a=[2 1;-4 -2]
b=[3 -1;-6 2]
c=a+b
d=a-b
 
e=a+1

result

a =

     2     1
    -4    -2


b =

     3    -1
    -6     2


c =

     5     0
   -10     0


d =

    -1     2
     2    -4


e =

     3     2
    -3    -1

>>

乘(矩陣總體)

code

clear
clc

a=[2 1;-4 -2]
b=[3 -1;-6 2]
 
c=a*b
 
d=b*a

result

a =

     2     1
    -4    -2


b =

     3    -1
    -6     2


c =

     0     0
     0     0


d =

    10     5
   -20   -10

>>

乘(矩陣元素)

code

clear
clc

a=[2 1;-4 -2]
b=[3 -1;-6 2]
 
c=3*a
 
d=a.*b

result

a =

     2     1
    -4    -2


b =

     3    -1
    -6     2


c =

     6     3
   -12    -6


d =

     6    -1
    24    -4

>>

乘(含參矩陣間的乘)

code

clear
clc

syms a b;
 
a=str2sym('[2 1 2;2 b a;1 a 3]')
 
x=str2sym('[1;-1;2]')
 
a*x

result

a =
 
[ 2, 1, 2]
[ 2, b, a]
[ 1, a, 3]
 
 
x =
 
  1
 -1
  2
 
 
ans =
 
           5
 2*a - b + 2
       7 - a
 
>>

加,減,乘(變量與數字矩陣)

code

clear
clc

syms m;
m*eye(3)
 
m-eye(3)
 
m+eye(3)

result

ans =
 
[ m, 0, 0]
[ 0, m, 0]
[ 0, 0, m]
 
 
ans =
 
[ m - 1,     m,     m]
[     m, m - 1,     m]
[     m,     m, m - 1]
 
 
ans =
 
[ m + 1,     m,     m]
[     m, m + 1,     m]
[     m,     m, m + 1]
 
>>

resource

  • [文檔] ww2.mathworks.cn/help/matlab
  • [文檔] ww2.mathworks.cn/help/simulink
  • [平臺] www.oschina.net
  • [平臺] gitee.com


感謝幫助 志成就 的人們。
matlab優秀,值得學習。基礎知識 + 專業知識 + matlab = ?
Simulink,用於仿真和基於模型的設計,值得學習。
該博文僅可用於測試與參考。學習

相關文章
相關標籤/搜索