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

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 1x1 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!

5 Kommentare

Kristofer - you may need to post a subset of the code (which generates the error) so that we can try and reproduce and understand the problem.
I have no problem doing this. It would be hard since I would need to post an experiment data file, 3 classdef files, and the possibly the script that is giving the errant call. I am not sure if I can boil the problem down to a lower level of complexity.
How are you calling it from the command window? The default for the command window (and using the expression form in general) for nargout to be automatically set to 1, to generate a single output. You would need to be using assignment form with multiple outputs for nargout to be set to beyond 1.
The function call is:
result(:,i) = transpose(staggered17D.LDV(n,m,:).z);
It is called within a function of class LDVexperiment. staggered17D is a class called LDVexperiment which contains a 3-dimensional matrix called LDV. LDV is a subclass called LDVpoint under staggered17D. z is a 'double' property of LDV. subsref had to be overloaded in order to handle the ':' operator in the subclass LDVpoint. This should return a 'double' vector of property z. i, n, and m are all integer indexes. result is initially undefined. This function call gives the following error.
Output argument "varargout{2}" (and maybe others) not assigned during call to "LDVpoint/subsref".
If this same line is executed from the MATLAB Command Window with all the required variables in the workspace, it does not give the error. The error only comes when this line is called from a function in the class LDVexperiment. Again, the error does not occur in MATLAB 2015a but does occur in MATLAB 2016a.
I hope this helps. I am grateful for any help you can provide.
I upgraded to MATLAB 2016b and the problem still exists.
I installed MATLAB 2015a on the same machine and the code works without error.

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

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

Weitere Antworten (0)

Kategorien

Mehr zu Entering Commands finden Sie in Hilfe-Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by