Mercurial > octave
view examples/code/@polynomial/polynomial.m @ 20726:25d676f9619c
Preface error() messages with name of function when possible.
* FIRfilter.m, subsasgn.m, get.m, polynomial.m, polynomial_superiorto.m,
set.m, subsasgn.m, subsref.m, Cell.cc, data.cc, graphics.in.h, toplev.cc,
urlwrite.cc, audiodevinfo.cc, symbfact.cc, CollocWt.cc, inputParser.m,
narginchk.m, nargoutchk.m, uicontrol.m, rgb2ind.m, textread.m, open.m,
__w2mpth__.m, fminbnd.m, pkg.m, pan.m, printd.m, rotate3d.m, zoom.m, eigs.m,
validatestring.m, __run_test_suite__.m, runtests.m, test.m:
Preface error() messages with name of function when possible.
author | Rik <rik@octave.org> |
---|---|
date | Thu, 19 Nov 2015 14:17:45 -0800 |
parents | c8240a60dd01 |
children | 73ab962bc52d |
line wrap: on
line source
## -*- texinfo -*- ## @deftypefn {Function File} {} polynomial () ## @deftypefnx {Function File} {} polynomial (@var{a}) ## Create a polynomial object representing the polynomial ## ## @example ## a0 + a1 * x + a2 * x^2 + @dots{} + an * x^n ## @end example ## ## @noindent ## from a vector of coefficients [a0 a1 a2 @dots{} an]. ## @end deftypefn function p = polynomial (a) if (nargin == 0) p.poly = [0]; p = class (p, "polynomial"); elseif (nargin == 1) if (strcmp (class (a), "polynomial")) p = a; elseif (isvector (a) && isreal (a)) p.poly = a(:).'; p = class (p, "polynomial"); else error ("@polynomial: expecting real vector"); endif else print_usage (); endif endfunction