c# - Passing MATLAB methods as delegates to .NET Object -


currently have matlab project using .net library. in matlab read in .dll , instantiate .net object developed, , pass data , it:

net.addassembly('mylibrary.dll'); mynetobj = mynamespace.myclass(); mynetobj.dowork(somematlabvariable); 

following matlab documentation (see here) can pass variables .net functions, have .net code call matlab methods/callbacks. documentation defines how use .net delegates matlab .net delegates (see here).

is possible pass (point to) matlab function .net delegate or action, can call callback .net object?

i found how pass matlab function handles delegates in c#. answer buried in matlab .net documentation.

in .net/c# code:

namespace somenamespace{    // create delegate appropriate input parameters , return types    public delegate void somedelegatetype();     public class someclass{       // create delegate matlab assign       public somedelegatetype somedelegate;       ...    } } 

in matlab:

// % instantiate .net object     classinstance = somenamespace.someclass(); // % assign matlab function handle .net delegate classinstance.somedelegate = somenamespace.somedelegatetype(@somematlabmethod);  function somematlabmethod()    ... end 

now when .net code calls somedelegate() call matlab function somematlabmethod() handle passed it.


Comments

Popular posts from this blog

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -