Mercurial > octave
comparison 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 |
comparison
equal
deleted
inserted
replaced
21058:759fcdf3666d | 21059:73ab962bc52d |
---|---|
1 function display (p) | 1 function display (p) |
2 | |
2 a = p.poly; | 3 a = p.poly; |
3 first = true; | 4 first = true; |
4 fprintf ("%s =", inputname (1)); | 5 printf ("%s =", inputname (1)); |
5 for i = 1 : length (a); | 6 for i = 1 : length (a); |
6 if (a(i) != 0) | 7 if (a(i) != 0) |
7 if (first) | 8 if (first) |
8 first = false; | 9 first = false; |
9 elseif (a(i) > 0) | 10 elseif (a(i) > 0) |
10 fprintf (" +"); | 11 printf (" +"); |
11 endif | 12 endif |
12 if (a(i) < 0) | 13 if (a(i) < 0) |
13 fprintf (" -"); | 14 printf (" -"); |
14 endif | 15 endif |
15 if (i == 1) | 16 if (i == 1) |
16 fprintf (" %g", abs (a(i))); | 17 printf (" %g", abs (a(i))); |
17 elseif (abs(a(i)) != 1) | 18 elseif (abs(a(i)) != 1) |
18 fprintf (" %g *", abs (a(i))); | 19 printf (" %g *", abs (a(i))); |
19 endif | 20 endif |
20 if (i > 1) | 21 if (i > 1) |
21 fprintf (" X"); | 22 printf (" X"); |
22 endif | 23 endif |
23 if (i > 2) | 24 if (i > 2) |
24 fprintf (" ^ %d", i - 1); | 25 printf (" ^ %d", i - 1); |
25 endif | 26 endif |
26 endif | 27 endif |
27 endfor | 28 endfor |
29 | |
28 if (first) | 30 if (first) |
29 fprintf (" 0"); | 31 printf (" 0"); |
30 endif | 32 endif |
31 fprintf ("\n"); | 33 printf ("\n"); |
34 | |
32 endfunction | 35 endfunction |