Filter löschen
Filter löschen

Use a DLL in Simulink

15 Ansichten (letzte 30 Tage)
rents85
rents85 am 5 Sep. 2012
Hi to all,
i've created a DLL in C# language and i want to use it in simulink.
I'm able to use in Matlab command line:
dllPath = fullfile('c:','OwnProtocol2.dll');
NET.addAssembly(dllPath);
OwnProtocol2.sendsMeasures.writeInt()
How can i do this in Simulink?
The version of Matlab is 2010b

Akzeptierte Antwort

Ryan G
Ryan G am 5 Sep. 2012
Bearbeitet: Ryan G am 5 Sep. 2012
You can use a s-function to call the DLL. To do this you would need a header file describing the functions inside the DLL so the s-function knows how to call the functions inside the code. I'm not overly familiar with C# so I'm not sure how easy this will be but I am sure it is doable.
After you write the code just make sure to include the DLL in the mex line.
For example
mex mysfun.c myDLL.dll
  2 Kommentare
rents85
rents85 am 5 Sep. 2012
Bearbeitet: rents85 am 5 Sep. 2012
Doesn't exist header file in C#...
Kaustubha Govind
Kaustubha Govind am 5 Sep. 2012
Not sure if you can link .NET assemblies directly against C-MEX S-functions (or any generic DLLs for that matter), but if you know how to invoke .NET assemblies from generic C/C++ DLLs, you can follow the same technique for C S-functions. Alternately, it might be easier to continue using your MATLAB code to call into the assembly. You can call MATLAB code from Simulink using the Interpreted MATLAB Function block or MATLAB S-Functions.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Startup and Shutdown finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by