I have generated a DLL from matalb model which sums two numbers and gives output. (a+b=c). How can I use that DLL in .NET C#

I have generated a DLL from matalb model which sums two numbers and gives output. (a+b=c). How can I use that DLL in .NET C#. I have used dumpbin.exe to find the generated C function. But none of them is of relevance to the operartion we are doing that is adding two numbers. How to use the DLL in .net?

Answers (1)

Are you sure that it is what you want to do? Note that at this point, your question has nothing to do with matlab anymore, and is simply about how to invoke dll from C#.
The answer to that is to use PInvoke, the details of which are off-topic for this forum. I guess the signature for your function would be:
[DllImport("yourdll.dll")]
public static extern double yourfun(double a, double b);
Note that you don't need to generate dlls to call matlab code from C#. You can simply use the COM automation server.

1 Comment

Thank you for the answer. The trouble we are facing is, if we make a matlab model with some inputs and outputs how can we use that in C#, not just a matlab function. I cannot find any function in the dll I generated than can be used as an "Entry Point" to add those two numbers. The problem with DLL's is that one cannot determine the name of functions it contains except the author. I used dumpbin to extract function names but none of them are not remotely close that add two numbers , what my model was supposed to do.
The matlab model was made by simulink, drag and drop, no matlab function is explicitly written. The problem is, we are not able to find that function which is adding the two numbers

Sign in to comment.

Categories

Find more on MATLAB in Help Center and File Exchange

Tags

Asked:

on 13 Jan 2016

Commented:

on 13 Jan 2016

Community Treasure Hunt

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

Start Hunting!