Interface C# with Matlab Simulink

Created at 03 Nov 2021, 12:34
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
Mikro's avatar

Mikro

Joined 20.06.2015

Interface C# with Matlab Simulink
03 Nov 2021, 12:34


Hi all,

I am trying ot interface C# with Matlab Simulink.

Unfortunately I have not been successfull to find a step by step solution to follow. As far as I could research I tried the following approaches.

Build Simulink Model DLL to use as Reference

Via embeded coder I setup a simple simulink model

and build the dll following this tutorial. When I try to reference the DLL in Visual Studio I get to error "Make sure the file is a valid assembly or COM component"

Unfortunately the created dlls seem only to work in C++ projects.
The MATLAB help also only points to C / C++ code. Now I'not deep enough in the differences between C# and C

 

Realtime Interface with MATLAB Simulink

It probably is possible and not too difficulty if you know how. Unfortunately I only find material on how to interact with actual hardware like here. Not helping with C# interface.

 

That what I got so far, I would greatly appreciate any hints or resources to dig deeper into the topic.

Happy trading!

 


@Mikro
Replies

amusleh
04 Nov 2021, 07:57

Hi,

C# is a different programming language, its a managed programming language with garbage collection that runs on top of .NET runtime.

You can call unmanaged C++ DLL functions on C#, check this tutorial please: How to call a c++ dll in C#.net code - CodeProject


@amusleh

Mikro
04 Nov 2021, 09:20

RE:

amusleh said:

Hi,

C# is a different programming language, its a managed programming language with garbage collection that runs on top of .NET runtime.

You can call unmanaged C++ DLL functions on C#, check this tutorial please: How to call a c++ dll in C#.net code - CodeProject

Hi,

thanks for the hint, I'll look into it!


@Mikro

Mikro
04 Nov 2021, 12:39

Has anyone succeeded in runing a life Simulink modell with data feed from a running cBot?


@Mikro