view examples/@polynomial/subsref.m @ 9284:567e3e4ab74d

fix up examples/@polynomial
author Robert T. Short <octave@phaselockedsystems.com>
date Sun, 31 May 2009 21:11:31 -0700
parents e2a179415bac
children 226f6d001ee2
line wrap: on
line source

function b = subsref (a, s)
  switch s.type
    case "()"
      ind = s.subs;
      b = polyval (fliplr(a.poly), ind{:});
    case "{}"
      ind = s.subs;
      b = polynomial (a.poly(ind{:}));
    case "."
      fld = s.subs;
      if (strcmp (fld, "poly"))
        b = a.poly;
      else
        error ("@polynomial/subsref: invalid property \"%s\"", fld);
      endif
  endswitch
endfunction