view examples/code/@polynomial/set.m @ 20535:caa5de39147e stable

maint: Complete deprecation of gmap40 colormap. * NEWS: Announce deprecation of function. * image.txi: Remove gmap40 from manual.
author Rik <rik@octave.org>
date Tue, 22 Sep 2015 04:47:25 -0700
parents c8240a60dd01
children
line wrap: on
line source

function s = set (p, varargin)
  s = p;
  if (length (varargin) < 2 || rem (length (varargin), 2) != 0)
    error ("set: expecting property/value pairs");
  endif
  while (length (varargin) > 1)
    prop = varargin{1};
    val = varargin{2};
    varargin(1:2) = [];
    if (ischar (prop) && strcmp (prop, "poly"))
      if (isvector (val) && isreal (val))
        s.poly = val(:).';
      else
        error ("set: expecting the value to be a real vector");
      endif
    else
      error ("set: invalid property of polynomial class");
    endif
  endwhile
endfunction