栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

MATLAB/matlab代码转化为python代码

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

MATLAB/matlab代码转化为python代码

MATLAB/matlab代码转化为python代码 方案1:使用smop

下载:https://pypi.org/project/smop/0.26.2/
转化效果
MATLAB代码

% matlab to python
clc;clear;close all;
varX = 1:1:200;
Y = sin(2*pi*0.01*varX);
figure;
plot(varX,Y);
title('matlab to python');
xlabel('x');
ylabel('y');

Python代码

# Generated with SMOP  0.41
from libsmop import *
# matlab.m

    # matlab to python
    clc
    clear
    close_('all')
    varX=arange(1,200,1)
# matlab.m:3
    Y=sin(dot(dot(dot(2,pi),0.01),varX))
# matlab.m:4
    figure
    plot(varX,Y)
    title('matlab to python')
    xlabel('x')
    ylabel('y')

转化完基本不能使用,还得一块块的修改
评价:不中

2. 其他方案

还有其他的尝试方案(没有试过,不想折腾了):

There are several tools for converting Matlab to Python code.

The only one that's seen recent activity (last commit from June 2018) is Small Matlab to Python compiler (also developed here: SMOP@chiselapp).

Other options include:

LiberMate: translate from Matlab to Python and SciPy (Requires Python 2, last update 4 years ago).
OMPC: Matlab to Python (a bit outdated).
Also, for those interested in an interface between the two languages and not conversion:

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:

http://bci2000.org/downloads/BCPy2000/Migration.html
On a different note, though I'm not a fortran fan at all, for people who might find it useful there is:

matlab2fortran

参考https://www.it1352.com/1601186.html

3. matlab迁移到python避坑

https://zhuanlan.zhihu.com/p/142516585

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/833465.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号