MATLAB: How to pass arguments in C# to a function with a VARARGIN signature that has been compiled to a .NET Assembly using MATLAB Builder NE

c-sharpcsharpMATLAB Builder NE

I have a MATLAB program that expects a VARARGIN as an input. I have compiled the function as a .NET Assembly, but I don't know how to pass the arguments in a C# project.

Best Answer

In order to pass the actual arguments, you can create an array of type MWArray containing the arguments of different types; this array will be accepted and interpreted correctly by the component, as follows:
// Declare variables.
MWArray[] in = new MWArray[3];
// Populate MWArray array with the actual arguments.
in[0] = new MWCharArray("String argument 1");
in[1] = new MWCharArray("String argument 2");
in[2] = new MWNumericArray(1.2); // Double argument.