Donbeo
Donbeo

Reputation: 17617

which programming languages can be called by matlab?

I would like to know which programming languages can be called by matlab.

for example I am quiet sure that matlab can use C function and maybe java.

I need this stuff for an industrial project so I need something that works well. For example I have found some tutorial to call python function in matlab but they look to me not very good and stable solution.

I am not an expert of the field and my knowledge of matlab is very limited. So please be patience with the answer.

This project is related to machine learning and the software will probably run on a cluster.

EDIT according to this post Embedding Python in MATLAB seems that there are problem when importing numpy using python. The only reason to use python in this environment is the numpy library. Without that it is almost useless to me.

Do you think that I will encounter similar problem using java or c calling some mathematics libraries?

Upvotes: 1

Views: 115

Answers (3)

Riko
Riko

Reputation: 11

I'm not sure about programming language but You can do it by EXE file by running run('C:\someCompiledProgram.exe') And if you need result you can use: [status, result] = system('command')

You can read about it here: http://nf.nci.org.au/facilities/software/Matlab/techdoc/ref/system.html

Upvotes: 0

bavaza
bavaza

Reputation: 11037

There are two main methods to achieve this:

  1. Write MEX functions, which is basically C/C++ or Fortran methods, which use Matlab-specific API. You can then call these methods like you would any function written in M-language file. This is described here.
  2. Call external libraries written in Java, .Net, C/C++, and COM servers. This is described here.

Both methods require good understanding of what you are doing, although I would argue that writing MEX function is much harder then referencing an existing library.

Upvotes: 1

Daniel
Daniel

Reputation: 36710

Most interfaces are listed here:

http://www.mathworks.de/de/help/matlab/external-interfaces.html

For Python I see different solutions:

  • COM on Windows platforms. This requires to register an application, check if this is possible and allowed on the cluster.
  • XMLRPC or SOAP. You may need to use Java-Classes in Matlab, but as you already realised this is very simple. Verify that the cluster has a Java VM available, many run matlab without java.
  • You can embed python code into c, which allows you to write mex functions which run c code: http://docs.python.org/2/extending/embedding.html
  • Use the command line interface for python.

Besides the documented limitations, I don't see any problem with these solution. If you are familiar with C or Matlab, I would choose the second or third option. This allows you to write a wrapper to access python with a very fundamental knowledge of matlab.

Upvotes: 2

Related Questions