Python调用MATLAB Install MATLAB Engine for Python
2016-01-20 09:20
639 查看
注意需要 Python是2.7, 3.3, and 3.4.噢
第一步:
用管理员权限打开cmd.exe
第二步:cd到MATLAB安装文件中的"\extern\engines\python"
第三步输入Python的安装目录+Python.exe setup.py install如下图
另外有人说要改环境变量,按照上面的教程不行就改改环境变量吧
另外粘一段MATLAB官方使用教程
This example shows how to call a MATLAB® script to compute the area of a triangle from Python®.
In your current folder, create a MATLAB script in a file named
After you save the file, start Python and call the script.
Specify
Convert the script to a function and call the function from the engine. Open the MATLAB editor to edit the file.
Delete the three statements. Then add a function declaration and save the file.
Call the new
The
相关博客整理如下
http://blog.sina.com.cn/s/blog_57a1cae80101osbj.html http://www.cnblogs.com/Vonng/p/4239822.html?utm_source=tuicool&utm_medium=referral
第一步:
用管理员权限打开cmd.exe
第二步:cd到MATLAB安装文件中的"\extern\engines\python"
第三步输入Python的安装目录+Python.exe setup.py install如下图
另外有人说要改环境变量,按照上面的教程不行就改改环境变量吧
另外粘一段MATLAB官方使用教程
Call User Script and Function from Python
This example shows how to call a MATLAB® script to compute the area of a triangle from Python®.In your current folder, create a MATLAB script in a file named
triarea.m.
b = 5; h = 3; a = 0.5*(b.* h)
After you save the file, start Python and call the script.
import matlab.engine eng = matlab.engine.start_matlab() eng.triarea(nargout=0)
a = 7.5000
Specify
nargout=0. Although the script prints output, it returns no output arguments to Python.
Convert the script to a function and call the function from the engine. Open the MATLAB editor to edit the file.
eng.edit('triarea',nargout=0)
Delete the three statements. Then add a function declaration and save the file.
function a = triarea(b,h) a = 0.5*(b.* h);
Call the new
triareafunction from the engine.
ret = eng.triarea(1.0,5.0) print(ret)
2.5
The
triareafunction returns only one output argument, so there is no need to specify
nargout.
相关博客整理如下
http://blog.sina.com.cn/s/blog_57a1cae80101osbj.html http://www.cnblogs.com/Vonng/p/4239822.html?utm_source=tuicool&utm_medium=referral
相关文章推荐
- 随笔1.19.2016
- 【matlab函数】conv2、filter2、imfilter的区别
- MATLAB GUI
- MATLAB GUI
- matlab unique函数
- matlab中 bsxfun函数
- 【zz】matlab 直方图匹配
- paper 3:matlab中save,load使用方法小结
- 【zz】matlab 求差集
- MATLAB中图像处理的函数
- pagerank算法的Matlab實現
- 用matlab实现视频截图字幕部分的拼接
- matlab读jpeg图像--jpeg toolbox的使用
- MATLAB入门
- 如何利用MATLAB并行计算缩短程序运行时间
- Matlab并行编程方法1
- MATLAB:1 matlab 与 c++ 数据存储的差异
- 【zz】matlab 腐蚀膨胀算法
- paper 2:图像处理常用的Matlab函数汇总
- MATLAB绘制平行六面体