Mercurial > hg > octave-nkf
annotate doc/interpreter/splineimages.m @ 20517:c3c1fb44f9b5
eliminate recursive make invocations in doc directory tree
* doc/module.mk: New file created from doc/Makefile.am,
doc/doxyhtml/Makefile.am, doc/liboctave/Makefile,
doc/interpreter/Makefile.am, and doc/refcard/Makefile.
* configure.ac (AC_OUTPUT): Don't generate doc/Makefile,
doc/doxyhtml/Makefile, or doc/interpreter/Makefile.
* Makefile.am (.NOTPARALLEL, AUTHORS, BUGS, INSTALL.OCTAVE):
Delete targets.
* config-images.sh, find-docstring-files.sh, geometryimages.m,
graphics_properties.mk, images.awk, interpimages.m, plotimages.m,
sparseimages.m, splineimages.m: Adapt to Makefile changes.
* octave.texi, liboctave.texi: Use unique version file names.
* etc/module.mk: Ensure icons build directory is created.
(etc/icons/octave-logo.ico): Fix file name.
* examples/module.mk (examples_code_SRC): New variable.
* doc/Makefile.am, doc/doxyhtml/Makefile.am,
doc/liboctave/Makefile.am, doc/interpreter/Makefile.am,
doc/refcard/Makefile: Delete.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 03 Jul 2015 19:33:19 -0400 |
parents | 606b05352351 |
children | d8992a16643c |
rev | line source |
---|---|
19898
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
19790
diff
changeset
|
1 ## Copyright (C) 2012-2015 Ben Abbott, Jonas Lundgren |
14509 | 2 ## |
3 ## This file is part of Octave. | |
4 ## | |
5 ## Octave is free software; you can redistribute it and/or modify it | |
6 ## under the terms of the GNU General Public License as published by | |
7 ## the Free Software Foundation; either version 3 of the License, or (at | |
8 ## your option) any later version. | |
9 ## | |
10 ## Octave is distributed in the hope that it will be useful, but | |
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 ## General Public License for more details. | |
14 ## | |
15 ## You should have received a copy of the GNU General Public License | |
16 ## along with Octave; see the file COPYING. If not, see | |
17 ## <http://www.gnu.org/licenses/>. | |
18 | |
20517
c3c1fb44f9b5
eliminate recursive make invocations in doc directory tree
John W. Eaton <jwe@octave.org>
parents:
19920
diff
changeset
|
19 function splineimages (d, nm, typ) |
19920
606b05352351
Backout cset 59ad278cfb98, use gnuplot for building doc images.
Rik <rik@octave.org>
parents:
19909
diff
changeset
|
20 graphics_toolkit ("gnuplot"); |
14509 | 21 set_print_size (); |
22 hide_output (); | |
20517
c3c1fb44f9b5
eliminate recursive make invocations in doc directory tree
John W. Eaton <jwe@octave.org>
parents:
19920
diff
changeset
|
23 outfile = fullfile (d, strcat (nm, ".", typ)); |
14509 | 24 if (strcmp (typ, "png")) |
25 set (0, "defaulttextfontname", "*"); | |
26 endif | |
27 if (strcmp (typ, "eps")) | |
28 d_typ = "-depsc2"; | |
29 else | |
16994
333243133364
Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents:
14526
diff
changeset
|
30 d_typ = ["-d" typ]; |
14509 | 31 endif |
32 | |
33 if (strcmp (typ, "txt")) | |
20517
c3c1fb44f9b5
eliminate recursive make invocations in doc directory tree
John W. Eaton <jwe@octave.org>
parents:
19920
diff
changeset
|
34 image_as_txt (d, nm); |
14509 | 35 elseif (strcmp (nm, "splinefit1")) ## Breaks and Pieces |
36 x = 2 * pi * rand (1, 200); | |
37 y = sin (x) + sin (2 * x) + 0.2 * randn (size (x)); | |
38 ## Uniform breaks | |
39 breaks = linspace (0, 2 * pi, 41); ## 41 breaks, 40 pieces | |
40 pp1 = splinefit (x, y, breaks); | |
41 ## Breaks interpolated from data | |
42 pp2 = splinefit (x, y, 10); ## 11 breaks, 10 pieces | |
43 ## Plot | |
44 xx = linspace (0, 2 * pi, 400); | |
45 y1 = ppval (pp1, xx); | |
46 y2 = ppval (pp2, xx); | |
17504
8b692d9ea54e
Use Octave coding conventions for m-files which generate images for manual.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
47 plot (x, y, ".", xx, [y1; y2]); |
8b692d9ea54e
Use Octave coding conventions for m-files which generate images for manual.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
48 axis tight; |
8b692d9ea54e
Use Octave coding conventions for m-files which generate images for manual.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
49 ylim ([-2.5 2.5]); |
8b692d9ea54e
Use Octave coding conventions for m-files which generate images for manual.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
50 legend ("data", "41 breaks, 40 pieces", "11 breaks, 10 pieces"); |
20517
c3c1fb44f9b5
eliminate recursive make invocations in doc directory tree
John W. Eaton <jwe@octave.org>
parents:
19920
diff
changeset
|
51 print (outfile, d_typ); |
14509 | 52 elseif (strcmp (nm, "splinefit2")) ## Spline orders |
53 ## Data (200 points) | |
54 x = 2 * pi * rand (1, 200); | |
55 y = sin (x) + sin (2 * x) + 0.1 * randn (size (x)); | |
56 ## Splines | |
57 pp1 = splinefit (x, y, 8, "order", 0); ## Piecewise constant | |
58 pp2 = splinefit (x, y, 8, "order", 1); ## Piecewise linear | |
59 pp3 = splinefit (x, y, 8, "order", 2); ## Piecewise quadratic | |
60 pp4 = splinefit (x, y, 8, "order", 3); ## Piecewise cubic | |
61 pp5 = splinefit (x, y, 8, "order", 4); ## Etc. | |
62 ## Plot | |
63 xx = linspace (0, 2 * pi, 400); | |
64 y1 = ppval (pp1, xx); | |
65 y2 = ppval (pp2, xx); | |
66 y3 = ppval (pp3, xx); | |
67 y4 = ppval (pp4, xx); | |
68 y5 = ppval (pp5, xx); | |
17504
8b692d9ea54e
Use Octave coding conventions for m-files which generate images for manual.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
69 plot (x, y, ".", xx, [y1; y2; y3; y4; y5]); |
8b692d9ea54e
Use Octave coding conventions for m-files which generate images for manual.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
70 axis tight; |
8b692d9ea54e
Use Octave coding conventions for m-files which generate images for manual.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
71 ylim ([-2.5 2.5]); |
8b692d9ea54e
Use Octave coding conventions for m-files which generate images for manual.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
72 legend ({"data", "order 0", "order 1", "order 2", "order 3", "order 4"}); |
20517
c3c1fb44f9b5
eliminate recursive make invocations in doc directory tree
John W. Eaton <jwe@octave.org>
parents:
19920
diff
changeset
|
73 print (outfile, d_typ); |
14509 | 74 elseif (strcmp (nm, "splinefit3")) |
75 ## Data (100 points) | |
76 x = 2 * pi * [0, (rand (1, 98)), 1]; | |
77 y = sin (x) - cos (2 * x) + 0.2 * randn (size (x)); | |
78 ## No constraints | |
79 pp1 = splinefit (x, y, 10, "order", 5); | |
80 ## Periodic boundaries | |
81 pp2 = splinefit (x, y, 10, "order", 5, "periodic", true); | |
82 ## Plot | |
83 xx = linspace (0, 2 * pi, 400); | |
84 y1 = ppval (pp1, xx); | |
85 y2 = ppval (pp2, xx); | |
17504
8b692d9ea54e
Use Octave coding conventions for m-files which generate images for manual.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
86 plot (x, y, ".", xx, [y1; y2]); |
8b692d9ea54e
Use Octave coding conventions for m-files which generate images for manual.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
87 axis tight; |
8b692d9ea54e
Use Octave coding conventions for m-files which generate images for manual.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
88 ylim ([-2 3]); |
8b692d9ea54e
Use Octave coding conventions for m-files which generate images for manual.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
89 legend ({"data", "no constraints", "periodic"}); |
20517
c3c1fb44f9b5
eliminate recursive make invocations in doc directory tree
John W. Eaton <jwe@octave.org>
parents:
19920
diff
changeset
|
90 print (outfile, d_typ); |
14509 | 91 elseif (strcmp (nm, "splinefit4")) |
92 ## Data (200 points) | |
93 x = 2 * pi * rand (1, 200); | |
94 y = sin (2 * x) + 0.1 * randn (size (x)); | |
95 ## Breaks | |
96 breaks = linspace (0, 2 * pi, 10); | |
97 ## Clamped endpoints, y = y" = 0 | |
98 xc = [0, 0, 2*pi, 2*pi]; | |
99 cc = [(eye (2)), (eye (2))]; | |
100 con = struct ("xc", xc, "cc", cc); | |
101 pp1 = splinefit (x, y, breaks, "constraints", con); | |
102 ## Hinged periodic endpoints, y = 0 | |
103 con = struct ("xc", 0); | |
104 pp2 = splinefit (x, y, breaks, "constraints", con, "periodic", true); | |
105 ## Plot | |
106 xx = linspace (0, 2 * pi, 400); | |
107 y1 = ppval (pp1, xx); | |
108 y2 = ppval (pp2, xx); | |
17504
8b692d9ea54e
Use Octave coding conventions for m-files which generate images for manual.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
109 plot (x, y, ".", xx, [y1; y2]); |
8b692d9ea54e
Use Octave coding conventions for m-files which generate images for manual.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
110 axis tight; |
8b692d9ea54e
Use Octave coding conventions for m-files which generate images for manual.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
111 ylim ([-1.5 1.5]); |
8b692d9ea54e
Use Octave coding conventions for m-files which generate images for manual.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
112 legend({"data", "clamped", "hinged periodic"}); |
20517
c3c1fb44f9b5
eliminate recursive make invocations in doc directory tree
John W. Eaton <jwe@octave.org>
parents:
19920
diff
changeset
|
113 print (outfile, d_typ); |
14509 | 114 elseif (strcmp (nm, "splinefit5")) |
115 ## Truncated data | |
116 x = [0, 1, 2, 4, 8, 16, 24, 40, 56, 72, 80] / 80; | |
117 y = [0, 28, 39, 53, 70, 86, 90, 79, 55, 22, 2] / 1000; | |
118 xy = [x; y]; | |
119 ## Curve length parameter | |
120 ds = sqrt (diff (x).^2 + diff (y).^2); | |
121 s = [0, cumsum(ds)]; | |
122 ## Constraints at s = 0: (x,y) = (0,0), (dx/ds,dy/ds) = (0,1) | |
123 con = struct ("xc", [0 0], "yc", [0 0; 0 1], "cc", eye (2)); | |
124 ## Fit a spline with 4 pieces | |
125 pp = splinefit (s, xy, 4, "constraints", con); | |
126 ## Plot | |
127 ss = linspace (0, s(end), 400); | |
128 xyfit = ppval (pp, ss); | |
17504
8b692d9ea54e
Use Octave coding conventions for m-files which generate images for manual.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
129 xyb = ppval (pp, pp.breaks); |
8b692d9ea54e
Use Octave coding conventions for m-files which generate images for manual.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
130 plot (x, y, ".", xyfit(1,:), xyfit(2,:), "r", xyb(1,:), xyb(2,:), "ro"); |
8b692d9ea54e
Use Octave coding conventions for m-files which generate images for manual.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
131 legend ({"data", "spline", "breaks"}); |
8b692d9ea54e
Use Octave coding conventions for m-files which generate images for manual.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
132 axis tight; |
8b692d9ea54e
Use Octave coding conventions for m-files which generate images for manual.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
133 ylim ([0 0.1]); |
20517
c3c1fb44f9b5
eliminate recursive make invocations in doc directory tree
John W. Eaton <jwe@octave.org>
parents:
19920
diff
changeset
|
134 print (outfile, d_typ); |
14509 | 135 elseif (strcmp (nm, "splinefit6")) |
136 ## Data | |
137 x = linspace (0, 2*pi, 200); | |
138 y = sin (x) + sin (2 * x) + 0.05 * randn (size (x)); | |
139 ## Add outliers | |
140 x = [x, linspace(0,2*pi,60)]; | |
141 y = [y, -ones(1,60)]; | |
142 ## Fit splines with hinged conditions | |
143 con = struct ("xc", [0, 2*pi]); | |
144 pp1 = splinefit (x, y, 8, "constraints", con, "beta", 0.25); ## Robust fitting | |
145 pp2 = splinefit (x, y, 8, "constraints", con, "beta", 0.75); ## Robust fitting | |
146 pp3 = splinefit (x, y, 8, "constraints", con); ## No robust fitting | |
147 ## Plot | |
148 xx = linspace (0, 2*pi, 400); | |
149 y1 = ppval (pp1, xx); | |
150 y2 = ppval (pp2, xx); | |
151 y3 = ppval (pp3, xx); | |
17504
8b692d9ea54e
Use Octave coding conventions for m-files which generate images for manual.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
152 plot (x, y, ".", xx, [y1; y2; y3]); |
8b692d9ea54e
Use Octave coding conventions for m-files which generate images for manual.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
153 legend ({"data with outliers","robust, beta = 0.25", ... |
8b692d9ea54e
Use Octave coding conventions for m-files which generate images for manual.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
154 "robust, beta = 0.75", "no robust fitting"}); |
8b692d9ea54e
Use Octave coding conventions for m-files which generate images for manual.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
155 axis tight; |
8b692d9ea54e
Use Octave coding conventions for m-files which generate images for manual.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
156 ylim ([-2 2]); |
20517
c3c1fb44f9b5
eliminate recursive make invocations in doc directory tree
John W. Eaton <jwe@octave.org>
parents:
19920
diff
changeset
|
157 print (outfile, d_typ); |
14509 | 158 endif |
19790
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
159 hide_output (); |
14509 | 160 endfunction |
161 | |
162 function set_print_size () | |
163 image_size = [5.0, 3.5]; # in inches, 16:9 format | |
164 border = 0; # For postscript use 50/72 | |
165 set (0, "defaultfigurepapertype", "<custom>"); | |
166 set (0, "defaultfigurepaperorientation", "landscape"); | |
167 set (0, "defaultfigurepapersize", image_size + 2*border); | |
168 set (0, "defaultfigurepaperposition", [border, border, image_size]); | |
169 endfunction | |
170 | |
171 ## Use this function before plotting commands and after every call to | |
172 ## print since print() resets output to stdout (unfortunately, gnpulot | |
173 ## can't pop output as it can the terminal type). | |
174 function hide_output () | |
175 f = figure (1); | |
176 set (f, "visible", "off"); | |
177 endfunction | |
178 | |
179 ## generate something for the texinfo @image command to process | |
20517
c3c1fb44f9b5
eliminate recursive make invocations in doc directory tree
John W. Eaton <jwe@octave.org>
parents:
19920
diff
changeset
|
180 function image_as_txt(d, nm) |
c3c1fb44f9b5
eliminate recursive make invocations in doc directory tree
John W. Eaton <jwe@octave.org>
parents:
19920
diff
changeset
|
181 fid = fopen (fullfile (d, strcat (nm, ".txt")), "wt"); |
14509 | 182 fputs (fid, "\n"); |
183 fputs (fid, "+---------------------------------+\n"); | |
184 fputs (fid, "| Image unavailable in text mode. |\n"); | |
185 fputs (fid, "+---------------------------------+\n"); | |
186 fclose (fid); | |
187 endfunction | |
188 | |
17504
8b692d9ea54e
Use Octave coding conventions for m-files which generate images for manual.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
189 |
14509 | 190 %!demo |
191 %! for s = 1:6 | |
192 %! splineimages (sprintf ("splinefit##d", s), "pdf") | |
193 %! endfor | |
194 |