Vardominator
Vardominator

Reputation: 16

Run MATLAB script from C# and return results

I am building a Windows Forms Application that uses a MATLAB back end. What is the best, possibly cleanest, way to do this? Furthermore, I need to grab the MATLAB output data and work with it in the Windows Forms program.

What I have done so far:

I am able to run the script without a problem. However, I cannot receive the output stream from MATLAB. I tried all of the solutions in the link above, but it does not work in my particular situation. I assume this has something to do with MATLAB.

Upvotes: 0

Views: 3487

Answers (1)

BobbyJ
BobbyJ

Reputation: 371

The best way is probably to use the COM interface supplied by Matlab.

You'll need to add a reference to your C# project referencing the Matlab Application, then instantiate an object of type MLApp, which will allow you to call Matlab. For a simple example refer to http://www.mathworks.com/help/matlab/matlab_external/call-matlab-function-from-a-c-client.html.

Upvotes: 2

Related Questions