MATLAB: Can’t I call superclass constructors of MATLAB objects in Debug mode in MATLAB 7.13 (R2011b)

constructordebugMATLABmultipleobjectsuperclass

I am having issues calling superclass constructors from the command line when in debug mode. For example, let us say I have a class D which inherits classes A, B and C.
Suppose the constructor for D is as follows:
function obj = D
obj = obj@A;
obj = obj@B;
obj = obj@C;
end
If I put a breakpoint in the constructor for right after the line:
obj = obj@A;
And then try to run the following from the MATLAB Command Window:
K>> obj = obj@B;
I get the following error:
'obj' is not a method of base class 'B'.
However, running the entire script outside the MATLAB Debugger works fine. Why is this?

Best Answer

The MATLAB debugger will not write the constructed object to the workspace until all appropriate constructors are called. In this case, it would be the following:
obj = obj@A;
obj = obj@B;
obj = obj@C;
Only after these three lines of code have executed will "obj" be available in the workspace for debugging.
Because of the way they are parsed in "classdef" MATLAB files, superclass constructors within other class constructors cannot be called from the command line from the MATLAB debugger.