Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Matlab and .NET 4.0 data communication

I have an algorithm implemented in Matlab and I'm planning to deploy it as a DLL for integration with a .NET project. The .NET project is a GUI based application a small part of which consists of displaying the results obtained from running the algorithm. The problem I currently have is that I need to display intermediary results. The algorithm is quite intricate and runs for a number of iterations (chosen by the user) and at the end of each iteration the GUI should be updated with the current data.

The best solution that I have in mind at the moment is for the Matlab thread to act as a tcp client to the local tcp server that I would start in my C# GUI app. However, I feel this approach is inefficient. I was wondering whether this could be achieved some other way.

like image 696
filipcampeanu Avatar asked Jan 11 '12 02:01

filipcampeanu


1 Answers

First of all, judging by your question, I guess you know about Matlab builder NE. It allows you to deploy a .NET DLL. If you don't know, try it.

Regarding your options:

1) You can pass a .NET object to your Matlab code that will serve as a communications means. Create a new instance of this class, and send to your Matlab code as input. The Matlab code will call the UpdateGui logic with each iteraion. The following example is in C#

 class GuiUpdater{
      public void UpdateGui(int param1,int param2){
           //Do update logic here.
      }
 } 

2) Compile your DLL as COM (It is also possible in Matlab Builder NE), and use COM communication.
3) Use the filesystem as communication means. Write to a file in Matlab, and read it in .NET.

like image 124
Andrey Rubshtein Avatar answered Sep 22 '22 23:09

Andrey Rubshtein