Newer
Older
function val = subsref(self, s)
% overloading subscripted reference for objects
% Dot Notation vs. Function Notation
%
% MATLAB classes support both function and dot notation syntax for calling methods.
% For example, if write is a method of the class of object nc, then calling
% write with function notation would be:
%
% nc = write(nc, 'mode');
%
% The equivalent method call using dot notation is:
%
% nc = nc.write('mode')
%
% However, in certain cases, the results for dot notation can differ with respect
% to how MATLAB dispatching works:
%
% If there is an overloaded subsref, it is invoked whenever using dot-notation.
% That is, the statement is first tested to see if it is subscripted assignment.
%
% If there is no overloaded subsref, then setColor must be a method of X.
% An ordinary function or a class constructor is never called using this notation.
%
% see help from substruct and subsref
% -----------------------------------
switch s(1).type
case '.'
switch s(1).subs
case {'write', 'save'}
builtin('subsref', self, s);
case {'autonan','autoscale'}
val = builtin('subsref', self, s);
otherwise
% call dynaload subsref
% ---------------------
val = subsref(self.dynaload, s);
end
end