view examples/polynomial/subsref.m @ 8223:0c91b9a17dcf

Commit missing files from previous change
author David Bateman <dbateman@free.fr>
date Thu, 16 Oct 2008 09:20:58 +0100
parents
children
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 ("subsref: unrecognized property \"%s\" of a polynomial", fld);
      endif
  endswitch
endfunction