In a call to an overloaded function, the actual function being called is decided by MATLAB based on the class of the objects in the entire argument list. MATLAB determines which argument has the highest object precedence and the class of
this object controls the method selection. Hence, in this case:
obj.(s(1).subs) = subsasgn(obj.(s(1).subs), s(2:end), val);
the variable 'val' is the dominant object and hence controls the function call. For a detailed explanation of this process and to manipulate the Object Precedence, please refer to the MATLAB documentation on Object Precedence.
You can manipulate the Object Precedence using the INFERIORTO and SUPERIORTO functions. Also, you can enforce the built-in SUBASGN function to be called by using:
obj.(s(1).subs) = builtin('subsasgn', obj.(s(1).subs), s(2:end), val);
Best Answer