Azzera filtri
Azzera filtri

Use a DLL in Simulink

15 visualizzazioni (ultimi 30 giorni)
rents85
rents85 il 5 Set 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

Risposta accettata

Ryan G
Ryan G il 5 Set 2012
Modificato: Ryan G il 5 Set 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 Commenti
rents85
rents85 il 5 Set 2012
Modificato: rents85 il 5 Set 2012
Doesn't exist header file in C#...
Kaustubha Govind
Kaustubha Govind il 5 Set 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.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Startup and Shutdown in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by