Matlab使用Python

Matlab内嵌Python

Matlab较新版本内置对Python支持。可在脚本内运行Python命令,执行Python脚本文件。其中关键之处是Matlab和Python数据类型之间的转换: Python参数传入和Python运行结果返回。官方文档有细节描述。不同版本Matlab对支持的Python版本有说明。Python环境是用conda安装的Python3.9, Matlab中配置如下(参考链接)

pyExec='C:\Users\*****\anaconda3\envs\py39\python.exe';
pyRoot = fileparts(pyExec);
p = getenv('PATH');
p = strsplit(p, ';');
addToPath = {
   
    pyRoot
    fullfile(pyRoot, 'Library', 'mingw-w64', 'bin')
    fullfile(pyRoot, 'Library', 'usr', 'bin')
    fullfile(pyRoot, 'Library', 'bin')
    fullfile(pyRoot, 'Scripts')
    fullfile(pyRoot, 'bin')
    };
p = [addToPath(:); p(:)];
p = unique(p, 'stable');
p = strjoin(p, ';');
setenv('PATH', p);

需要的Python包用conda环境管理安装,可在m脚本内加载使用!


资料参考

使用conda环境
matlab-spmd-and-coolprop-cpython-library
配置您的系统使用 Python
matlab调用python的各种方法举例子详解
在MATLAB里使用Python
官方: 从 MATLAB 中调用 Python
官方: 从 Python 将数据传递到 MATLAB
ITK and MATLAB Python Tutorial
Using MATLAB and Python Together

相关推荐

  1. Matlab使用Python

    2024-01-24 09:38:01       55 阅读
  2. PythonMATLAB使用

    2024-01-24 09:38:01       41 阅读
  3. C++/Python/MATLAB检查内存使用情况

    2024-01-24 09:38:01       54 阅读
  4. 手写数字识别——使用MATLABpython的实现

    2024-01-24 09:38:01       44 阅读
  5. Matlab 使用

    2024-01-24 09:38:01       27 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-01-24 09:38:01       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-01-24 09:38:01       100 阅读
  3. 在Django里面运行非项目文件

    2024-01-24 09:38:01       82 阅读
  4. Python语言-面向对象

    2024-01-24 09:38:01       91 阅读

热门阅读

  1. Flutter 屏幕适配之相对尺寸适配

    2024-01-24 09:38:01       44 阅读
  2. uniapp 中使用 rem 以及改变窗口动态刷新页面

    2024-01-24 09:38:01       39 阅读
  3. Node.js Shell 脚本开发指南(中)

    2024-01-24 09:38:01       46 阅读
  4. 第六章 使用 SQL Search - 词干提取和分解

    2024-01-24 09:38:01       48 阅读
  5. 2401llvm,合并clang语法树

    2024-01-24 09:38:01       44 阅读
  6. MRD市场需求文档

    2024-01-24 09:38:01       52 阅读
  7. windows 安装sql server 华为云文档

    2024-01-24 09:38:01       53 阅读
  8. React和Vue的生态系统有何不同?

    2024-01-24 09:38:01       56 阅读
  9. Pytorch Tensor 维度变换学习记录

    2024-01-24 09:38:01       58 阅读