Mercurial > octave
view examples/code/@polynomial/display.m @ 21059:73ab962bc52d
doc: Use newer coding conventions in examples/code directory.
* FIRfilter.m, FIRfilter_aggregation.m, display.m, subsasgn.m, subsref.m,
display.m, end.m, get.m, numel.m, plot.m, polynomial.m,
polynomial_superiorto.m, polyval.m, roots.m, set.m, subsasgn.m, subsref.m,
celldemo.cc, fortrandemo.cc, funcdemo.cc, globaldemo.cc, oct_demo.cc,
paramdemo.cc, stringdemo.cc:
Use newer coding conventions in examples/code directory.
author | Rik <rik@octave.org> |
---|---|
date | Wed, 13 Jan 2016 16:21:24 -0800 |
parents | c8240a60dd01 |
children | fd97ed44f2da |
line wrap: on
line source
function display (p) a = p.poly; first = true; printf ("%s =", inputname (1)); for i = 1 : length (a); if (a(i) != 0) if (first) first = false; elseif (a(i) > 0) printf (" +"); endif if (a(i) < 0) printf (" -"); endif if (i == 1) printf (" %g", abs (a(i))); elseif (abs(a(i)) != 1) printf (" %g *", abs (a(i))); endif if (i > 1) printf (" X"); endif if (i > 2) printf (" ^ %d", i - 1); endif endif endfor if (first) printf (" 0"); endif printf ("\n"); endfunction