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


(b) 複素行列の表現

>> A = [1+i 2+i; 3 1-2i]
A =
   1.0000 + 1.0000i   2.0000 + 1.0000i
   3.0000             1.0000 - 2.0000i
>> A = [1+j 2+j; 3 1-2j]
A =
   1.0000 + 1.0000i   2.0000 + 1.0000i
   3.0000             1.0000 - 2.0000i
>> real(A)
ans =
     1     2
     3     1
>> imag(A)
ans =
     1     1
     0    -2

(c) 行列のサイズ

>> A = [1 2 3; 4 5 6]
A =
     1     2     3
     4     5     6
>> size(A)
ans =
     2     3
>> size(A,1)
ans =
     2
>> size(A,2)
ans =
     3

(d) 対角行列とブロック対角行列

>> A = diag([1 2])
A =
     1     0
     0     2
>> A = blkdiag(1,2)
A =
     1     0
     0     2
>> A1 = [1 2; 3 4]
A1 =
     1     2
     3     4
>> A2 = [5 6]
A2 =
     5     6
>> A = blkdiag(A1,A2)
A =
     1     2     0     0
     3     4     0     0
     0     0     5     6

(e) 単位行列と零行列

>> I2 = eye(2)
I2 =
     1     0
     0     1
>> O23 = zeros(2,3)
O23 =
     0     0     0
     0     0     0

(f) 転置行列と共役転置行列

>> A = [1+i 2+i; 3 1-2i]
A =
   1.0000 + 1.0000i   2.0000 + 1.0000i
   3.0000             1.0000 - 2.0000i
>> A.'
ans =
   1.0000 + 1.0000i   3.0000          
   2.0000 + 1.0000i   1.0000 - 2.0000i
>> A'
ans =
   1.0000 - 1.0000i   3.0000          
   2.0000 - 1.0000i   1.0000 + 2.0000i
>> A = [1 2; 4 5]
A =
     1     2
     4     5
>> A'
ans =
     1     4
     2     5

(g) 行列式

>> A = [1 0 2; 2 1 0; -1 -1 0]
A =
     1     0     2
     2     1     0
    -1    -1     0
>> det(A)
ans =
    -2

(h) 逆行列

>> A = [1 0 2; 2 1 0; -1 -1 0]
A =
     1     0     2
     2     1     0
    -1    -1     0
>> inv(A)
ans =
         0    1.0000    1.0000
         0   -1.0000   -2.0000
    0.5000   -0.5000   -0.5000

(i) 行列のランク

>> A = [1 3 5; 2 6 10]
A =
     1     3     5
     2     6    10
>> rank(A)
ans =
     1

(j) トレース

>> A = [1 2; -2 -4]
A =
     1     2
    -2    -4
>> trace(A)
ans =
    -3