Sorry if this question has already been asked, but I couldn't find quite what I've been looking for. I was wondering if there is a way to work with a MATLAB compiled c-shared library in C# without using MCR/MATLAB (or in general any additional installation), e.g. to use this simple function test.m, compile it via mcc into a .dll and then use that 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 entirely sure if it's possible (let alone easy) to do this, but even using this simple example I can't get it to work in C#, though this may also have to do with my very limited C# experience. I suppose in this example I would have to use IntPtr to deal with the matrices, i.e. something like:
[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)
and then later try to get the data out of x,y,z via working around a bit with Marshal ? I suppose I'm also making some rather obvious mistakes, e.g. I'm not sure I can just pass ref double[,] to the dll and expect it to work.
I suppose if absolutely necessary I could use MCR (which would make things a lot easier), but right now I'm constrained.
Thanks in advance for your help.