Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Connecting to an existing Matlab COM server via python

145 views
Skip to first unread message

Srinath Avadhanula

unread,
Oct 25, 2004, 9:38:19 PM10/25/04
to
Hello,

I wanted to connect to an already existing MATLAB application from
python.

From the MATHWORKS documentation at:

http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_external/ch07cl24.html

I see that to connect to an already existing MATLAB application, I
have to do the equivalent of the following Visual Basic code:

h = GetObject(, "matlab.application")

Note It is important to use the syntax shown above to connect
with an existing MATLAB automation server. Omit the first argument,
and make sure that the second argument reads exactly as shown.

My question is, how do I replicate this from python? I tried the
following:

>>> import win32com.client
>>> o = win32com.client.GetObject(Class='matlab.application')
Traceback (most recent call last):
File "<interactive input>", line 1, in ?
File "C:\Program_Files\Python23\Lib\site-packages\win32com\client\__init__.py",
line 71, in GetObject
return GetActiveObject(Class, clsctx)
File "C:\Program_Files\Python23\Lib\site-packages\win32com\client\__init__.py",
line 80, in GetActiveObject
dispatch = pythoncom.GetActiveObject(resultCLSID)
com_error: (-2147221021, 'Operation unavailable', None, None)

I tried searching for relevant things in Google, but couldn't find
anything close to this. I also read the docstring of
win32com.client.GetObject, but couldn't figure out the equivalent.

I already know how to start a new MATLAB COM Server. Something like

>>> o = win32com.client.Dispatch('matlab.application')

works fine. But I specifically want to connect to an existing server.

I wanted to do this in order to set breakpoints from VIM.


Thanks :)
Srinath

Rajesh Kumar Raja

unread,
Jan 25, 2016, 8:05:12 AM1/25/16
to
Hi Srinath,

try using the python option win32com.client.GetActiveObject('matlab.application')

This will help you to get the current com object provided you already created using Dispatch.

Regards,
Rajesh Kumar Raja.


Srinath Avadhanula <srinath...@yahoo.com> wrote in message <Pine.LNX.4.58.0410251835040.22414@bartok>...

Bo Li

unread,
Jan 25, 2016, 9:29:09 AM1/25/16
to
In case that you are not aware of, you can connect to an exist MATLAB session using Python Engine since R2015b:

http://www.mathworks.com/help/matlab/matlab_external/connect-python-to-running-matlab-session.html


"Rajesh Kumar Raja" wrote in message <n856i0$ak0$1...@newscl01ah.mathworks.com>...
0 new messages