Home > classes > @history > subsref.m

subsref

PURPOSE ^

SUBSREF Define field name indexing for history objects.

SYNOPSIS ^

function varargout = subsref(h, index)

DESCRIPTION ^

 SUBSREF Define field name indexing for history objects.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 DESCRIPTION: SUBSREF Define field name indexing for history objects.

 EXAMPLES:

  nesting level == 1

    >>  h1      = h(1);
    >>  name    = h.name;
    >>  version = h.version;
    >>  plist   = h.plist;
    >>  inhist  = h.inhist;
    >>  invars  = h.invars;
    >>  n       = h.n;
    >>  pn      = h.pn;
    >>  created = h.created;
    >>  consver = h.consver;

 VERSION: $Id: subsref.m,v 1.1 2007/06/14 14:46:49 ingo Exp $

 HISTORY: 06-06-07 Diepholz
             Creation

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function varargout = subsref(h, index)
0002 % SUBSREF Define field name indexing for history objects.
0003 %
0004 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0005 %
0006 % DESCRIPTION: SUBSREF Define field name indexing for history objects.
0007 %
0008 % EXAMPLES:
0009 %
0010 %  nesting level == 1
0011 %
0012 %    >>  h1      = h(1);
0013 %    >>  name    = h.name;
0014 %    >>  version = h.version;
0015 %    >>  plist   = h.plist;
0016 %    >>  inhist  = h.inhist;
0017 %    >>  invars  = h.invars;
0018 %    >>  n       = h.n;
0019 %    >>  pn      = h.pn;
0020 %    >>  created = h.created;
0021 %    >>  consver = h.consver;
0022 %
0023 % VERSION: $Id: subsref.m,v 1.1 2007/06/14 14:46:49 ingo Exp $
0024 %
0025 % HISTORY: 06-06-07 Diepholz
0026 %             Creation
0027 %
0028 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0029 
0030 switch length(index)
0031   case 1
0032     switch index.type
0033 
0034       % INFO: h1 = h(2)
0035       %            h(1)
0036       case '()'
0037         if length (index.subs) == 1
0038 
0039           % assure that the number of outputs matches
0040           if nargout == 0
0041             plot(h(index.subs{1}))
0042           elseif nargout == 1
0043             varargout{1} = h(index.subs{1});
0044           else
0045             error('### the number of outputs does not match. Please use two outputs.')
0046           end
0047 
0048         % INFO: h(2,1) not possible
0049         else % length (index.subs) == 2
0050           error ('### Do not use two indices.');
0051         end
0052 
0053       % INFO: name    = h.name;
0054       %       version = h.version;
0055       %       plist   = h.plist;
0056       %           ...
0057       case '.'
0058         fieldName = index.subs;
0059         eval(sprintf('varargout{1} = h.%s;', fieldName));
0060 
0061       otherwise
0062         error('### only ''.'' and ''()'' indexing methods for history objects are allowed.');
0063     end
0064   otherwise
0065     error('### nesting level for history objects is too large.');
0066 end
0067 
0068 % END
0069

Generated on Wed 04-Jul-2007 19:03:10 by m2html © 2003