1 前言
matlab擅长矩阵运算和数学原理验证,python具有丰富的函数库和实时仿真验证功能。接力开发会涉及到两者的转换。
从matlab到python的翻译,就是根据要实现的功能随时选择python合适的库和语句。
推荐官网:
scipy : Table of Rough MATLAB-NumPy Equivalents
numpy和matlab的对应
http://mathesaurus.sourceforge.net/matlab-numpy.html
推荐博文:
从 Matlab 到 NumpyNumpy 和 Matlab 比较:https://blog.csdn.net/weixin_37887248/article/details/81941462
matlab和python对应函数:https://www.cnblogs.com/Hand-Head/articles/9017593.html
对应译文:https://blog.csdn.net/ouening/article/details/54667921,
网盘:http://pan.baidu.com/s/1c2013W0,非常感谢!
numpy与matlab互转操作:https://blog.csdn.net/goodstudy168/article/details/81077825
2条件选择
2.1比较选择
即关系运算符 > <等。
matlab:
>> a = rand(4,4)
>> a =
0.8147 0.6324 0.9575 0.9572
0.9058 0.0975 0.9649 0.4854
0.1270 0.2785 0.1576 0.8003
0.9134 0.5469 0.9706 0.1419>> index = (abs(a(:,1))<0.5) & (abs(a(:,2))<0.5)
>> b = a(index,:)
b =
0.1270 0.2785 0.1576 0.8003
python1: DataFrame变量
获取的index变量必须是pd.Series类型,可以通过iloc顺便转换。