Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Calling a Matlab script from another language (C++, Java, ...)

Subject: Calling a Matlab script from another language (C++, Java, ...)

From: Tristan Marly

Date: 9 Jun, 2002 05:02:47

Message: 1 of 5

I would like to know if there are some existing interfaces to call a
matlab script from some other language like C++ or Java, without
having to call a system command, and without using the compiler for
matlab ?
 Moreover, is there some way to call a remote matlab script using
corba, or any other method (may be by adding some code to the remote
script in order to be called) ?


  Tristan

Subject: Calling a Matlab script from another language (C++, Java, ...)

From: Jeff

Date: 10 Jun, 2002 07:30:49

Message: 2 of 5

Hello Tristan,


I believe that this can be done (at least for C++) by using the
Matlab compiler to convert your m-file to C++. You will have to
convert your script to a function though. See the help on the Matlab
compiler or the help on mbuild() and mcc() within Matlab. I'm not
sure if Java is supported yet.


Jeff


Tristan Marly wrote:
>
>
> I would like to know if there are some existing interfaces to call a
> matlab script from some other language like C++ or Java, without
> having to call a system command, and without using the compiler for
> matlab ?
> Moreover, is there some way to call a remote matlab script using
> corba, or any other method (may be by adding some code to the remote
> script in order to be called) ?
>
> Tristan
>

Subject: Calling a Matlab script from another language (C++, Java, ...)

From: Steven Goncalo

Date: 10 Jun, 2002 10:10:50

Message: 3 of 5

For my application I created a Corba Interface using Java at the Matlab
end, and wrote a fairly simple top level matlab script that opened the
interface then waited for a command to come in. The top level matlab
script gets a command string from my main application via the Corba
call, then does an eval() to execute the command, which is typically the
name of a script. I defined several other Corba functions that call from
MatLab back to the main application to get/return specific data items.

My main application just starts off MatLab in batch mode executing the
top level script.

Tristan Marly wrote:

> I would like to know if there are some existing interfaces to call a
> matlab script from some other language like C++ or Java, without
> having to call a system command, and without using the compiler for
> matlab ?
> Moreover, is there some way to call a remote matlab script using
> corba, or any other method (may be by adding some code to the remote
> script in order to be called) ?
>
> Tristan

Subject: Calling a Matlab script from another language (C++, Java, ...)

From: Elaine Stryker

Date: 14 Jan, 2011 13:47:04

Message: 4 of 5

Is there any chance you would be willing to share the code you used to do this CORBA to Matlab business? I'm looking for examples of ways to do that by going through Java and it seems like you've done essentially what I need and I would love to see an example in actual code.

Steven Goncalo <default@res.raytheon.com> wrote in message <3D04B36A.26EB3210@res.raytheon.com>...
> For my application I created a Corba Interface using Java at the Matlab
> end, and wrote a fairly simple top level matlab script that opened the
> interface then waited for a command to come in. The top level matlab
> script gets a command string from my main application via the Corba
> call, then does an eval() to execute the command, which is typically the
> name of a script. I defined several other Corba functions that call from
> MatLab back to the main application to get/return specific data items.
>
> My main application just starts off MatLab in batch mode executing the
> top level script.
>
> Tristan Marly wrote:
>
> > I would like to know if there are some existing interfaces to call a
> > matlab script from some other language like C++ or Java, without
> > having to call a system command, and without using the compiler for
> > matlab ?
> > Moreover, is there some way to call a remote matlab script using
> > corba, or any other method (may be by adding some code to the remote
> > script in order to be called) ?
> >
> > Tristan
>

Subject: Calling a Matlab script from another language (C++, Java, ...)

From: Yair Altman

Date: 15 Jan, 2011 17:32:04

Message: 5 of 5

"Elaine Stryker" <egarbarine@gmail.com> wrote in message <igpk4o$qo2$1@fred.mathworks.com>...
> Is there any chance you would be willing to share the code you used to do this CORBA to Matlab business? I'm looking for examples of ways to do that by going through Java and it seems like you've done essentially what I need and I would love to see an example in actual code.


Elaine - this thread is 9 years old. the chances that any of the original posters still monitor the thread are very slim...

To the point, I suggest not using CORBA since this is quite an old technology by now (it was hot at the time of the original post, 2002, but not today). There are plenty of more modern approaches for a Java-Matlab interface. Most of them center around RMI/JMI, JNI or COM. Here are a few links to get you started:

http://code.google.com/p/matlabcontrol/wiki/ApproachesToControl
http://code.google.com/p/matlabcontrol/
http://jamal.sourceforge.net/about.shtml
http://jmatlink.sourceforge.net/
http://www.jstatcom.com/jmatlab.html
https://jna.dev.java.net/servlets/BrowseList?list=users&by=thread&from=935824

...and of course, a series of articles on UndocumentedMatlab.com: http://undocumentedmatlab.com/blog/tag/JMI/

Yair Altman
http://UndocumentedMatlab.com

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us