How to use compiled MATLAB DLL in C # without MCR / MATLAB?

Sorry if this question has already been asked, but I could not find what I was looking for. I was wondering if there is a way to work with the compiled c-shared MATLAB library in C # without using MCR / MATLAB (or any additional installation at all), for example. to use this simple test.m function, compile it through mcc into a .dll, and then use it in C #:

[x,y,z]=test(a,b,c)
%x,a are integers
%y,z,b are matrices
%c is a string (which e.g. could be used to switch between several modes)


x=a*a;
y=b*b-b;
z=y*y;

I'm not quite sure that this is possible (not to mention it is easy), but even with this simple example, I cannot get it to work in C #, although this may also be relevant to my very limited C # experience. I believe that in this example I would have to use IntPtr to process matrices, for example:

[DllImport("test.dll",EntryPoint="mlfTest")]
public static extern void testfunction([In] numargout, ref IntPtr x, ref IntPtr y, ref IntPtr z, [In] IntPtr a, [In] ref double[,] b, [In] ref c)

x, y, z, ? , , . , ref double [,] dll , .

, , MCR ( ), .

.

+5
2

, , , . , MATLAB , MATLAB, . MATLAB, . ? .

, MCR - , ?

, , MATLAB, MATLAB Coder. ( ) MATLAB, . , C/++.

+3

, , MATLAB Compiler, MCR.

MATLAB # MATLAB COM Automation. . :

using System;

namespace testMATLAB
{
    class Program
    {
        static void Main(string[] args)
        {
            MLApp.MLAppClass matlab = new MLApp.MLAppClass();

            System.Array pr = new double[4];
            pr.SetValue(11, 0);
            pr.SetValue(12, 1);
            pr.SetValue(13, 2);
            pr.SetValue(14, 3);

            System.Array pi = new double[4];
            pi.SetValue(1, 0);
            pi.SetValue(2, 1);
            pi.SetValue(3, 2);
            pi.SetValue(4, 3);

            matlab.PutFullMatrix("a", "base", pr, pi);

            System.Array prresult = new double[4];
            System.Array piresult = new double[4];

            matlab.GetFullMatrix("a", "base", ref prresult, ref piresult);
        }
    }
}
+1

All Articles