I have a MATLAB function that I've compiled into a .net library. The function is a simple one that takes a character array as an input and a numeric array as output:
function insert = money(dateLimit) .. insert = [1 2];
The function works fine when no function arguments are specified (a default argument is provided inside the function)
Dim sf As New SpreadFinder.SpreadFinder
Dim output = sf.money()
As soon as an argument is specified .net complains. I'm thinking this should be easy and has been done before but searching through MATLAB documentation doesn't offer much help.
Here's what I've tried. The sf.money() overload for the function with arguments is (numArgsOut as Integer, argsOut as MWArray, argsIn as MWArray) and hence that's what I've tried. What am I missing?
Dim sf As New SpreadFinder.SpreadFinder
Dim inputArgs(1) As Arrays.MWCharArray
Dim dateLimitString As String = "some string"
inputArgs(0) = New Arrays.MWCharArray(dateLimitString)
Dim outputArgs(1) As Arrays.MWNumericArray
outputArgs(0) = New Arrays.MWNumericArray()
sf.money(1, outputArgs, inputArgs)
Gives
System.NullReferenceException : Object reference not set to an instance of an object. at MathWorks.MATLAB.NET.Utility.MWMCR.EvaluateFunction(String functionName, Int32 numArgsOut, Int32 numArgsIn, MWArray[] argsIn) at MathWorks.MATLAB.NET.Utility.MWMCR.EvaluateFunction(String functionName, Int32 numArgsOut, MWArray[]& argsOut, MWArray[] argsIn) at SpreadFinder.SpreadFinder.money(Int32 numArgsOut, MWArray[]& argsOut, MWArray[] argsIn)