Menu

Third Party Bridge with Matlab, R and Python

Safee
2012-09-21
2012-09-21
  • Safee

    Safee - 2012-09-21

    Matlab Bridge

    To use Matlab bridge, the user first needs to install the freely available Matlab Compiler Runtime. It is available at this location:
    http://www.mathworks.com/products/compiler/mcr/index.html

    For further information, you can also review the following material:
    http://www.mathworks.com/products/netbuilder/
    http://www.mathworks.com/products/netbuilder/examples.html

    The steps are as follows:

    a. Compile a .net DLL (e.g. 'Model.Dll') by using Matlab and place it in the same folder as 'ELECANS.EXE'.

    b. Next, open the rules editor and insert Reference to the DLL in the Rules Editor

    c. Insert the following code on top of the C# rules file:

    using Model;
    using MathWorks.MATLAB.NET.ComponentData;
    using MathWorks.MATLAB.NET.Arrays;
    using MathWorks.MATLAB.NET.Utility;

    d. Then, just develop the following code template, and compile your new rules dll.

    Model ModelObj = new Model ();

    MWArray bParam = ((MathWorks.MATLAB.NET.Arrays.MWArray)(InputParameter-1));

    MWArray aParam= ((MathWorks.MATLAB.NET.Arrays.MWArray)(InputParameter-2));

    MWNumericArray bParamArray = ((MWNumericArray)bParam).ToVector(MWArrayComponent.Real);

    MWNumericArray aParamArray = ((MWNumericArray)aParam).ToVector(MWArrayComponent.Real);

    MWArray[] ReturnArray= wntModelObj.NameOfMatlabFunction(1, InputValue, bParamArray, aParamArray);

    double returnValue = ((MWNumericArray) (ReturnArray[0])). ToScalarDouble ();

     

    Last edit: Safee 2012-09-21
  • Safee

    Safee - 2012-09-21

    Python Bridge

    ELECANS can be linked with Python codes by using Python.net.
    For information on the Python.net project, please follow the link: http://pythonnet.sourceforge.net/

     

    Last edit: Safee 2012-09-21

Log in to post a comment.