trilli
trilli

Reputation: 45

How to stream soft real time data from Matlab to C# application?

I’m currently using Matlab to acquire data from an eye tracker using a specific toolbox. After that, the stream of data has to be slightly processed and sent to a C# application (.NET framework). The entire data flow has to be as much real-time as possible (data acquired and processed in no more than 30 ms).

I need a way to interface the data acquired from Matlab and the C# application. I was thinking to use a text file, but in this case there should exist a synchronization between the writing and reading operation. Are there any methods to synchronize a Matlab I/O operation with a C# I/O operation?

Upvotes: 3

Views: 713

Answers (1)

mhopeng
mhopeng

Reputation: 1081

I can suggest three approaches:

  1. Use file-based synchronization with a flag file. Use one file for the data, and another file to indicate that the data is ready to be read. The flag file is deleted after the data file is read. This is easy to implement and does not require any additional Matlab toolboxes, but has potential problems when you try to achieve high data rates or high-speed/low latency synchronization. You would basically have to try it and see if it works on your hardware.
  2. Compile your Matlab program into a library (a .dll) that you can call from your C# application. Then you only have one application. Use the MATLAB Compiler SDK for this.
  3. Use TCP sockets to communicate between the two programs. This has the benefit of allowing the two programs to run on different computers and it also works on the same computer. A Matlab example is given here.

Upvotes: 1

Related Questions