MATLAB: Getting error “Output argument “varargout{2}” (and maybe others) not assigned during call to “MyClass/subsref”.”

classMATLABoopsubsref

I am getting this error "Output argument "varargout{2}" (and maybe others) not assigned during call to "MyClass/subsref"."
A couple of things: subsref is overloaded for MyClass. varargout should return a 1×1 cell. varargout{1} is assigned appropriately just before the function return. The function call works when called from the Command Window but not when called from another higher level class. This code works on another computer with the Matlab 2015a but not on my computer with Matlab 2016a.
I have no idea what else to do. I really need this code to work on this computer. Could it be a compiler error or am I missing something? Thank you!

Best Answer

You have to add the following code to the class in order to overload the Matlab default for numArgumentsFromSubscript(obj,s,indexingContext):
function n = numArgumentsFromSubscript(obj,s,indexingContext)
n = 1;
end