将MATLAB代码转换为Python的工具 [英] A tool to convert MATLAB code to Python
问题描述
我的MS论文中有一堆MATLAB代码,现在我想将其转换为Python(使用numpy/scipy和matplotlib)并作为开源分发.我知道MATLAB与Python科学库之间的相似之处,并且手动转换它们的时间不会超过两周(前提是我每天都会努力一段时间).我想知道是否已经有任何工具可以进行转换.
I have a bunch of MATLAB code from my MS thesis which I now want to convert to Python (using numpy/scipy and matplotlib) and distribute as open-source. I know the similarity between MATLAB and Python scientific libraries, and converting them manually will be not more than a fortnight (provided that I work towards it every day for some time). I was wondering if there was already any tool available which can do the conversion.
推荐答案
有多种工具可将Matlab转换为Python代码.
There are several tools for converting Matlab to Python code.
唯一见过的近期活动(2018年6月的最后一次提交)是 S mall M atlab t o P ython编译器(也在此处开发:
The only one that's seen recent activity (last commit from June 2018) is Small Matlab to Python compiler (also developed here: SMOP@chiselapp).
其他选项包括:
- LiberMate: translate from Matlab to Python and SciPy (Requires Python 2, last update 4 years ago).
- OMPC: Matlab to Python (a bit outdated).
此外,对于那些对两种语言之间的接口以及 not 转换感兴趣的人:
Also, for those interested in an interface between the two languages and not conversion:
-
pymatlab
:通过将数据发送到MATLAB工作区并对其进行操作来与Python进行通信使用脚本并拉回结果数据. - Python-Matlab虫洞:支持双向交互. li>
- Python-Matlab桥:从Python内部使用Matlab,为iPython提供matlab_magic,从ipython内执行普通的matlab代码.
- PyMat :从Python控制Matlab会话.
-
pymat2
:看似被遗弃的PyMat的延续. -
mlabwrap
,oct2py
:从Python内部运行GNU Octave命令. -
pymex
:还将Python解释器嵌入到Matlab中文件交换. -
matpy
:以多种方式访问MATLAB:创建变量,访问.mat文件,直接接口到MATLAB引擎(需要安装MATLAB). - MatPy :Python软件包,用于数值线性代数并使用类似MatLab的界面进行绘图.
pymatlab
: communicate from Python by sending data to the MATLAB workspace, operating on them with scripts and pulling back the resulting data.- Python-Matlab wormholes: both directions of interaction supported.
- Python-Matlab bridge: use Matlab from within Python, offers matlab_magic for iPython, to execute normal matlab code from within ipython.
- PyMat: Control Matlab session from Python.
pymat2
: continuation of the seemingly abandoned PyMat.mlabwrap
, mlabwrap-purepy: make Matlab look like Python library (based on PyMat).oct2py
: run GNU Octave commands from within Python.pymex
: Embeds the Python Interpreter in Matlab, also on File Exchange.matpy
: Access MATLAB in various ways: create variables, access .mat files, direct interface to MATLAB engine (requires MATLAB be installed).- MatPy: Python package for numerical linear algebra and plotting with a MatLab-like interface.
顺便说一句,在这里查找其他迁移技巧可能会有所帮助:
Btw might be helpful to look here for other migration tips:
换句话说,尽管我根本不是fortran
粉丝,但对于可能会觉得有用的人来说,是:
On a different note, though I'm not a fortran
fan at all, for people who might find it useful there is:
这篇关于将MATLAB代码转换为Python的工具的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!