Matlab - 矩阵基本操作
1. 矩阵的输入
右值是用方括号表示;
, 逗号或空格分隔元素 ; 分号分隔行
>> A = [-1, 6; 7, 11]
A =
-1 6
7 11
2. 矩阵的加减
>> C = A + B;
>> D = A - B;
3. 矩阵的共轭转置
>> B = A';
4. 矩阵的转置
>> B = A.';
5. 矩阵与矩阵相乘
>> A = [12 3; -1 6]; B = [4 2; 9 1]; >> A*B ans = 75 27 50 4
6. 矩阵点乘
>> A.*B ans = 48 6 -9 6
7. 矩阵点除
>> A = [2 4 6 8]; B = [2 2 3 1]; >> C = A ./ B C = 1 2 2 8
>> C = A .\ B
C =
1.0000 0.5000 0.5000 0.1250
8. 矩阵元素平方
>> B = [2 4; -1 6]; >> B.^2 ans = 4 16 1 36