Matlab is a powerful tool for everyone that works with sensor data. Recently, I have been developing some scripts in Matlab to make sense of some sensor data because it is very handy for prototyping algorithms. The final system, however, was to be implemented in C#. I thought I would have to reimplement all my algorithms, but then I found out that it is possible to connect C# applications to Matlab in several ways. I ended up calling my Matlab scripts using the COM interface.
This is how I did it:
1) Create a project in Visual Studio
2) Right-click on References > Add Reference
3) In the COM tab select “Matlab Aplication” and click OK
4) The following code creates the COM object
MLApp.MLApp matlab = new MLApp.MLApp();
5) Now you can access all Matlab functionality through the methods provided by this object. You can send commands with the Execute method which returns a string with the console output.