用于MATLAB会话的python解释器 - iPython notebook

时间:2015-09-21 15:50:17

标签: python matlab ipython ipython-notebook

我想从iPython笔记本运行MATLAB代码。

我安装了以下库:

  • ZeroMQ-4.0.4-miru1.0-x64.exe程序
  • pyzmq-14.7.0
  • pymatbridge-0.5.2
  • matplotlib-1.4.3.win-AMD64的py2.7.exe
  • python 2.7

我正在尝试将MATLAB与iPython连接,以便使用以下代码运行MATLAB命令:

import sys
sys.path.append('C:\Python27\Lib\site-packages\pymatbridge')
​
​
from pymatbridge import Matlab
mlab = Matlab()
​
mlab = Matlab(executable='C:\Program Files\MATLAB\R2013a\bin\matlab')
mlab.start()

但是,获得了以下信息:

Starting MATLAB on ZMQ socket tcp://127.0.0.1:42987
Send 'exit' command to kill the server
............................................................MATLAB session timed out after 60 seconds

当运行%load_ext pymatbridge时,iPython-magic命令返回:

The pymatbridge module is not an IPython extension.

你能帮忙吗?

1 个答案:

答案 0 :(得分:0)

如果不是不可逆转地绑定到pymatbridge,那么就是这样:

% MATLAB script to setup ZeroMQ-MATLAB session ( neutral agent-to-agent PUB/SUB )

clear all;

if ~ispc
    s1 = zmq( 'subscribe', 'ipc', 'MATLAB' );   %% using IPC transport on <localhost>

else
    disp( '0MQ IPC not supported on windows. Setup TCP transport class instead' )
    disp( 'Setting up TCP' )
    s1 = zmq( 'subscribe', 'tcp', 'localhost', 5555 );

end

recv_data1 = [];                                %% setup RECV buffer

more details >>> Most efficient way to exchange data between MATLAB and ...?