Matrix Operations
- 此文档 matrices 为二维数值数组, 包括 scalars 和 vectors
MATLAB 中有两种 Matlab Arithmetic Operations: matrix operations 和 Matlab Array Operations.
Matrix Operations 就是 Linear Algebra 中的矩阵操作, 区别于 Matlab Array Operations 的元素与元素之间的运算.
Operators
基本的双目或单目矩阵数值运算都能通过运算符实现.
| Operator | Equivalent Function | Description | Arguments |
|---|---|---|---|
+ | plus | addition | binary, compatible arrays |
- | minus | subtraction | binary, compatible arrays |
* | mtimes | multiplication | binary, matrices |
/ | mrdivide | right division | binary, matrices |
\ | mldivide | left division | binary, matrices |
^ | mpower | powers | binary, matrices |
' | ctranspose | complex conjugate transpose | single, matrices |
.' | transpose | non conjugate transpose | single, matrices |
说明
- 以上表格中
compatible arrays指的是运算对象可以是 N-D arrays, 只要满足 Matlab Compatible Array Sizes matrices指的是一般矩阵运算和标量运算- 如
A * B要满足 A 列数与 B 行数相等 - 或
c * B,A * c中 c 为 scalar
- 如
- 也可以看出, 所有运算对象须为 matrices 的运算对应函数都有
m, 表示为 “矩阵运算” - 加法
+和减法-对于 matrix operations 和 array operations 没有区别 - 乘法
*只要有一个运算对象是 scalar, 则相当于.* - 右除
B / A即- 又等价于利用求逆函数 inv:
B * inv(A) - A 为 scalar 时相当于
./ - 特别地, A 可为非方阵, 此时相当于利用广义逆函数 pinv:
B * pinv(A)
- 又等价于利用求逆函数 inv:
- 左除
A \ B即- 又等价于利用求逆函数 inv:
inv(A) * B - A 为 scalar 时相当于
.\ - 特别地, A 可为非方阵, 此时相当于利用广义逆函数 pinv:
pinv(A) * B
- 又等价于利用求逆函数 inv:
- 幂次 要求至少一个运算对象为 scalar (下用小写字母表示)
a ^ B即- 即相当于矩阵指数函数 expm:
expm(log(a) * B) - ++特别注意++
- 这里幂次运算符的计算公式是, 其中 分别是以 特征向量为列向量的矩阵和特征值为对角线的矩阵, 即
- 因此这种算法要求 的特征向量线性无关, 所以 才可逆
- 而函数 expm 的计算公式就是 , 对 无任何要求
- 因此
^可能与函数 expm 结果不一致, 特别地,^会报错
- 即相当于矩阵指数函数 expm:
A ^ a即a ^ b相当于a .^ b
- 转置
.'是唯一有句号.但不是 Matlab Array Operations 的矩阵运算符