The above Macro Subroutine can be translated to the following Macro Function:
Function Calculate(A As Range, b As Range) As Variant
MLOpen
MLPutMatrix "A", A
MLPutMatrix "b", b
MLEvalString "x = myfunc(A, b)"
MLGetVar "x", Calculate
End Function
The inputs to MLPutMatrix are Ranges. MLGetVar is used to write the "x" from the MATLAB workspace to the "Calculate" variable.
Note Excel Macro Functions only support one output range. For MATLAB functions with multiple outputs, consider writing to multiple ranges directly.
MLGetMatrix "x", "x"
MLGetMatrix "y", "y"
Best Answer