Skip to content
Snippets Groups Projects
subsref.m 922 B
function val = subsref(self, s)
% Subscripted assignment for object dynaload
% overloading subscripted reference for objects
% Dot Notation vs. Function Notation
%
% see help from substruct and subsref
%
% $Id$

switch (length(s))
  case 3
    switch s(1).type
      case '.'
        val = get(self, s(1).subs);
        val = val.(s(2).subs);
        val = val.(s(3).subs);
      otherwise
        error('Invalid type.')
    end
  case 2
    switch s(1).type
      case '.'
        val = get(self, s(1).subs);
        val = val.(s(2).subs);
      otherwise
        error('Invalid type.')
    end
  case 1
    switch s.type
      case '()'
        if (length(s.subs) ~= 1)
          error('Only single indexing is supported.');
        end
        val = get(self, s.subs{1});
      case '.'
        val = get(self, s.subs);
      otherwise
        error('Invalid type.')
    end
end