(A) 行列,ベクトルの定義と操作


(a) 行列,ベクトルの定義と演算

>> A = [1 2 3; 4 5 6; 7 8 9]
A =
     1     2     3
     4     5     6
     7     8     9
>> A = [1 2 3
4 5 6
7 8 9]
A =
     1     2     3
     4     5     6
     7     8     9
>> b = [1; 2; 3]
b =
     1
     2
     3
>> b = [1
2
3]
b =
     1
     2
     3
>> c = [1 2 3]
c =
     1     2     3
>> A = [1 2 3; 4 5 6; 7 8 9]
A =
     1     2     3
     4     5     6
     7     8     9
>> A(2,3)
ans =
     6
>> A(2:3,1:2)
ans =
     4     5
     7     8
>> A(1,:)
ans =
     1     2     3
>> A(:,1)
ans =
     1
     4
     7
>> b = [1; 2; 3]
b =
     1
     2
     3
>> b(2)
ans =
     2
>> c = [1 2 3]
c =
     1     2     3
>> c(3)
ans =
     3
>> A = [0 1; -2 -3], B = [1 -2; 0 -3]
A =
     0     1
    -2    -3
B =
     1    -2
     0    -3
>> C = A + B
C =
     1    -1
    -2    -6
>> D = A - B
D =
    -1     3
    -2     0
>> E = A*B
E =
     0    -3
    -2    13
>> F = A^3
F =
     6     7
   -14   -15 
>> G = A\B
G =
   -1.5000    4.5000
    1.0000   -2.0000
>> H = A/B
H =
         0   -0.3333
   -2.0000    2.3333