Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calling a MATLAB function from C#

I developed a MATLAB function, and I'm looking for a way to call that function from another C# application and pass some parameters to it and get the results in the C# program.

I heard that I can use Dynamic Data Exchange (DDE) or COM objects, but have can I do it?

like image 577
Wassim AZIRAR Avatar asked May 05 '11 17:05

Wassim AZIRAR


1 Answers

There is nice example in the MATLAB Central.

It shows three ways on how to communicate with MATLAB:

  1. COM
  2. MATLAB .NET Bulider
  3. MATLAB compiler

COM (I do not have any experience with it)

Cons: MATLAB is required to be installed on the target computer.

MATLAB .NET builder compiles your MATLAB code to the .NET assembly and you can use it directly.

Pros: MATLAB is not required to be installed on the target computer

Cons: It's expensive

MATLAB compiler compiles your MATLAB code into a C/C++ library or EXE file. You can use it through P/Invoke.

Pros: MATLAB is not required to be installed on the target computer

Cons: It's expensive, a lot of P/Invoke.

like image 155
Lukas Kabrt Avatar answered Sep 20 '22 16:09

Lukas Kabrt