功能 | matlab量 | python量 |
---|---|---|
打印 | disp() | print() |
求特征根 | eig() | a, b = np.linalg.eig() a[0], a[1] |
矩阵幂运算 | .^2 | ** |
矩阵乘法 | .* | * |
复数实部虚部 | imag() real() | ().real/().imag |
查找数组判断 | find(C==x) | np.where(G==b) |
画图 | plot() | plt.plot() |
取整 | ceil floor | numpy ceil floor |
matlab中的常用取整:
MATLAB取整函数
1)fix(x) : 截尾取整.
fix( [3.12 -3.12])
ans =
3 -3
(2)floor(x):不超过x 的最大整数.(高斯取整)
floor( [3.12 -3.12])
ans =
3 -4
(3)ceil(x) : 大于x 的最小整数
ceil( [3.12 -3.12])
ans =
4 -3
(4)四舍五入取整
round(3.12 -3.12)
ans =
0
round([3.12 -3.12])
ans =
3 -3
MATLAB中四个取整函数具体使用方法如下:
Matlab取整函数有: fix, floor, ceil, round.
fix
朝零方向取整,如fix(-1.3)=-1; fix(1.3)=1;
floor
朝负无穷方向取整,如floor(-1.3)=-2; floor(1.3)=1;
ceil
朝正无穷方向取整,如ceil(-1.3)=-1; ceil(1.3)=2;
round
四舍五入到最近的整数,如round(-1.3)=-1;round(-1.52)=-2;round(1.3)=1;round(1.52)=2。
- matlab
switch case用法
switch 变量
case 变量取值(a)
case 变量取值(b)
...
4.matlab 断点测试
直接对应行,单击生成小红点