本文主要是介绍珠联璧合 II:Jupyter Notebook 与 Matlab 之融合,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
作者:韩少真(西北大学) || 展金永(对外经济贸易大学)
连享会 - lianxh.cn
相关推文:珠联璧合 I:Jupyter Notebook 和 Stata 关联 (windows系统)
文章目录
- 1. 准备工作-关联前提
- 2. 安装 MATLAB 的 Python 拓展
- 2.1 获取扩展的路径
- 2.2 安装 MATLAB 的 Python 扩展
- 3.在 Python 中安装 MATLAB _kernel 包
- 关于我们
虽然 Stata 已经有了专门的空间计量模块,但由于多数做空间计量的经济学家都在使用 Matlab,使得很多前沿的方法和模型目前都还是只有 Matlab 程序。因此,我们
言归正传,就学术研究而言,目前在很多 Top 期刊上发表的论文都会综合使用多种计量方法和软件来完成文中的实证分析工作。这意味着,我们需要一个工作平台,以便有效整合手头的 2-3 中软件和语言,不必频繁地地转场。
今天要介绍的 Anaconda 就是这么个玩意儿,其配置的 Jupyter Notebook 便是我们所需的分析和写作平台。你可以在一份文档中同时使用 Stata,Python,R 多种语言来执行实证分析,同时使用 Markdown 等写作,并将完成后的文档输出为 Word,PDF,HTML 甚至是幻灯片等多种格式。
1. 准备工作-关联前提
首先,请按助教提供教程安装 Anaconda 和 MATLAB,并检验 Anaconda 和 MATLAB 是否已经成功安装在本机电脑上。
2. 安装 MATLAB 的 Python 拓展
2.1 获取扩展的路径
打开 MATLAB 的安装路径(如果忘记可以看下 MATLAB 安装教程的第六步),依次打开extern、engines、Python 文件夹,进入 Python 文件夹。然后点击地址栏,复制 Python 文件夹的路径地址,如下图所示:
我的电脑为D:\Polyspace\R2019a\extern\engines\ Python
,根据 MATLAB 安装的地址不同,D:\Polyspace\R2019a\
可能有所差异,请根据个人安装状况更改。
2.2 安装 MATLAB 的 Python 扩展
- 通过
开始- Anaconda 3(64-bit)- Anaconda Powershell prompt
,打开 Anaconda Powershell prompt。如果直接打开执行下面的操作无法正常关联 Python 和 MATLAB,则需要右击选择以管理员身份运行,重新进行接下来的操作。
- 在powershell中依次输入以下命令并按回车键执行
cd "D:\Polyspace\R2019a\extern\engines\ Python "Python setup.py install
- 执行结果如下所示,表明扩展安装成功
(base) PS C:\Users\mailshaozhen> cd D:\Polyspace\R2019a\extern\engines\ Python
(base) PS D:\Polyspace\R2019a\extern\engines\ Python > Python setup.py install
running install
running build
running build_py
creating build
creating build\lib
creating build\lib\ MATLAB
copying dist\ MATLAB \mlarray.py -> build\lib\ MATLAB
copying dist\ MATLAB \mlexceptions.py -> build\lib\ MATLAB
copying dist\ MATLAB \__init__.py -> build\lib\ MATLAB
creating build\lib\ MATLAB \engine
copying dist\ MATLAB \engine\basefuture.py -> build\lib\ MATLAB \engine
copying dist\ MATLAB \engine\engineerror.py -> build\lib\ MATLAB \engine
copying dist\ MATLAB \engine\enginehelper.py -> build\lib\ MATLAB \engine
copying dist\ MATLAB \engine\enginesession.py -> build\lib\ MATLAB \engine
copying dist\ MATLAB \engine\fevalfuture.py -> build\lib\ MATLAB \engine
copying dist\ MATLAB \engine\futureresult.py -> build\lib\ MATLAB \engine
copying dist\ MATLAB \engine\ MATLAB engine.py -> build\lib\ MATLAB \engine
copying dist\ MATLAB \engine\ MATLAB future.py -> build\lib\ MATLAB \engine
copying dist\ MATLAB \engine\__init__.py -> build\lib\ MATLAB \engine
creating build\lib\ MATLAB \_internal
copying dist\ MATLAB \_internal\mlarray_sequence.py -> build\lib\ MATLAB \_internal
copying dist\ MATLAB \_internal\mlarray_utils.py -> build\lib\ MATLAB \_internal
copying dist\ MATLAB \_internal\__init__.py -> build\lib\ MATLAB \_internal
running install_lib
creating D:\ Anaconda 3\Lib\site-packages\ MATLAB
creating D:\ Anaconda 3\Lib\site-packages\ MATLAB \engine
copying build\lib\ MATLAB \engine\basefuture.py -> D:\ Anaconda 3\Lib\site-packages\ MATLAB \engine
copying build\lib\ MATLAB \engine\engineerror.py -> D:\ Anaconda 3\Lib\site-packages\ MATLAB \engine
copying build\lib\ MATLAB \engine\enginehelper.py -> D:\ Anaconda 3\Lib\site-packages\ MATLAB \engine
copying build\lib\ MATLAB \engine\enginesession.py -> D:\ Anaconda 3\Lib\site-packages\ MATLAB \engine
copying build\lib\ MATLAB \engine\fevalfuture.py -> D:\ Anaconda 3\Lib\site-packages\ MATLAB \engine
copying build\lib\ MATLAB \engine\futureresult.py -> D:\ Anaconda 3\Lib\site-packages\ MATLAB \engine
copying build\lib\ MATLAB \engine\ MATLAB engine.py -> D:\ Anaconda 3\Lib\site-packages\ MATLAB \engine
copying build\lib\ MATLAB \engine\ MATLAB future.py -> D:\ Anaconda 3\Lib\site-packages\ MATLAB \engine
copying build\lib\ MATLAB \engine\_arch.txt -> D:\ Anaconda 3\Lib\site-packages\ MATLAB \engine
copying build\lib\ MATLAB \engine\__init__.py -> D:\ Anaconda 3\Lib\site-packages\ MATLAB \engine
copying build\lib\ MATLAB \mlarray.py -> D:\ Anaconda 3\Lib\site-packages\ MATLAB
copying build\lib\ MATLAB \mlexceptions.py -> D:\ Anaconda 3\Lib\site-packages\ MATLAB
creating D:\ Anaconda 3\Lib\site-packages\ MATLAB \_internal
copying build\lib\ MATLAB \_internal\mlarray_sequence.py -> D:\ Anaconda 3\Lib\site-packages\ MATLAB \_internal
copying build\lib\ MATLAB \_internal\mlarray_utils.py -> D:\ Anaconda 3\Lib\site-packages\ MATLAB \_internal
copying build\lib\ MATLAB \_internal\__init__.py -> D:\ Anaconda 3\Lib\site-packages\ MATLAB \_internal
copying build\lib\ MATLAB \__init__.py -> D:\ Anaconda 3\Lib\site-packages\ MATLAB
byte-compiling D:\ Anaconda 3\Lib\site-packages\ MATLAB \engine\basefuture.py to basefuture.c Python -37.pyc
byte-compiling D:\ Anaconda 3\Lib\site-packages\ MATLAB \engine\engineerror.py to engineerror.c Python -37.pyc
byte-compiling D:\ Anaconda 3\Lib\site-packages\ MATLAB \engine\enginehelper.py to enginehelper.c Python -37.pyc
byte-compiling D:\ Anaconda 3\Lib\site-packages\ MATLAB \engine\enginesession.py to enginesession.c Python -37.pyc
byte-compiling D:\ Anaconda 3\Lib\site-packages\ MATLAB \engine\fevalfuture.py to fevalfuture.c Python -37.pyc
byte-compiling D:\ Anaconda 3\Lib\site-packages\ MATLAB \engine\futureresult.py to futureresult.c Python -37.pyc
byte-compiling D:\ Anaconda 3\Lib\site-packages\ MATLAB \engine\ MATLAB engine.py to MATLAB engine.c Python -37.pyc
byte-compiling D:\ Anaconda 3\Lib\site-packages\ MATLAB \engine\ MATLAB future.py to MATLAB future.c Python -37.pyc
byte-compiling D:\ Anaconda 3\Lib\site-packages\ MATLAB \engine\__init__.py to __init__.c Python -37.pyc
byte-compiling D:\ Anaconda 3\Lib\site-packages\ MATLAB \mlarray.py to mlarray.c Python -37.pyc
byte-compiling D:\ Anaconda 3\Lib\site-packages\ MATLAB \mlexceptions.py to mlexceptions.c Python -37.pyc
byte-compiling D:\ Anaconda 3\Lib\site-packages\ MATLAB \_internal\mlarray_sequence.py to mlarray_sequence.c Python -37.pyc
byte-compiling
这篇关于珠联璧合 II:Jupyter Notebook 与 Matlab 之融合的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!