If your add-in throws the error:
Error in myfunc: Object reference not set to an instance of an object
The likely cause is that the MATLAB® function used by the add-in returns a variable number of outputs.
Add-ins using code run on a MATLAB Production Server™ instance do not support MATLAB functions that return a variable number of outputs. You can either rewrite your MATLAB function to return a fixed number of outputs, or you can create an add-in that runs locally to your Excel® installation.