annotate scripts/testfun/private/dump_demos.m @ 22765:01aae08a0105

maint: Rename variables to match documentation in m-files. * fminbnd.m, javaclasspath.m, ls_command.m, isprop.m, roots.m, bicg.m, cgs.m, qmr.m, dump_demos.m: Rename variables in function to match documentation. * normest1.m, AbsRel_norm.m, colstyle.m, frame2im.m, rotate.m: Rename variables in documentation to match function. * recycle.m: Rename variable 'state' to 'val' in documentation, and then throughout code. * untabify.m: Rename variable 'dblank' to 'deblank_arg'. * speed.m: Add comment about why variable names can't match documentation.
author Rik <rik@octave.org>
date Mon, 14 Nov 2016 14:55:41 -0800
parents 3a2b891d0b33
children ef4d915df748
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
22323
bac0d6f07a3e maint: Update copyright notices for 2016.
John W. Eaton <jwe@octave.org>
parents: 22318
diff changeset
1 ## Copyright (C) 2010-2016 Søren Hauberg
18874
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
2 ##
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
3 ## This file is part of Octave.
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
4 ##
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
6 ## under the terms of the GNU General Public License as published by
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22338
diff changeset
7 ## the Free Software Foundation; either version 3 of the License, or
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22338
diff changeset
8 ## (at your option) any later version.
18874
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
9 ##
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22338
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22338
diff changeset
13 ## GNU General Public License for more details.
18874
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
14 ##
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
15 ## You should have received a copy of the GNU General Public License
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
16 ## along with Octave; see the file COPYING. If not, see
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
17 ## <http://www.gnu.org/licenses/>.
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
18
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
19 ## -*- texinfo -*-
22262
a41c83fc601b dump_demos.m: Backout a8a9c275e12d and fix filesep on non-unix
Andreas Weber <andy.weber.aw@gmail.com>
parents: 22220
diff changeset
20 ## @deftypefn {} {} dump_demos ()
a41c83fc601b dump_demos.m: Backout a8a9c275e12d and fix filesep on non-unix
Andreas Weber <andy.weber.aw@gmail.com>
parents: 22220
diff changeset
21 ## @deftypefnx {} {} dump_demos (@var{dirs})
a41c83fc601b dump_demos.m: Backout a8a9c275e12d and fix filesep on non-unix
Andreas Weber <andy.weber.aw@gmail.com>
parents: 22220
diff changeset
22 ## @deftypefnx {} {} dump_demos (@var{dirs}, @var{mfile})
a41c83fc601b dump_demos.m: Backout a8a9c275e12d and fix filesep on non-unix
Andreas Weber <andy.weber.aw@gmail.com>
parents: 22220
diff changeset
23 ## @deftypefnx {} {} dump_demos (@var{dirs}, @var{mfile}, @var{fmt})
18895
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 18877
diff changeset
24 ## Produce a script, with the name specified by @var{mfile}, containing
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 18877
diff changeset
25 ## the demos in the directories, @var{dirs}. The demos are assumed to produce
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 18877
diff changeset
26 ## graphical output, whose renderings are saved with the specified format,
18874
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
27 ## @var{fmt}.
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
28 ##
22262
a41c83fc601b dump_demos.m: Backout a8a9c275e12d and fix filesep on non-unix
Andreas Weber <andy.weber.aw@gmail.com>
parents: 22220
diff changeset
29 ## The defaults for each input are;
a41c83fc601b dump_demos.m: Backout a8a9c275e12d and fix filesep on non-unix
Andreas Weber <andy.weber.aw@gmail.com>
parents: 22220
diff changeset
30 ##
a41c83fc601b dump_demos.m: Backout a8a9c275e12d and fix filesep on non-unix
Andreas Weber <andy.weber.aw@gmail.com>
parents: 22220
diff changeset
31 ## @table @var
a41c83fc601b dump_demos.m: Backout a8a9c275e12d and fix filesep on non-unix
Andreas Weber <andy.weber.aw@gmail.com>
parents: 22220
diff changeset
32 ## @item @var{dirs}
a41c83fc601b dump_demos.m: Backout a8a9c275e12d and fix filesep on non-unix
Andreas Weber <andy.weber.aw@gmail.com>
parents: 22220
diff changeset
33 ## @code{@{"plot/appearance", "plot/draw", "plot/util", "image"@}}
a41c83fc601b dump_demos.m: Backout a8a9c275e12d and fix filesep on non-unix
Andreas Weber <andy.weber.aw@gmail.com>
parents: 22220
diff changeset
34 ##
a41c83fc601b dump_demos.m: Backout a8a9c275e12d and fix filesep on non-unix
Andreas Weber <andy.weber.aw@gmail.com>
parents: 22220
diff changeset
35 ## @item @var{mfile}
a41c83fc601b dump_demos.m: Backout a8a9c275e12d and fix filesep on non-unix
Andreas Weber <andy.weber.aw@gmail.com>
parents: 22220
diff changeset
36 ## @qcode{"dump.m"}
a41c83fc601b dump_demos.m: Backout a8a9c275e12d and fix filesep on non-unix
Andreas Weber <andy.weber.aw@gmail.com>
parents: 22220
diff changeset
37 ##
a41c83fc601b dump_demos.m: Backout a8a9c275e12d and fix filesep on non-unix
Andreas Weber <andy.weber.aw@gmail.com>
parents: 22220
diff changeset
38 ## @item @var{fmt}
a41c83fc601b dump_demos.m: Backout a8a9c275e12d and fix filesep on non-unix
Andreas Weber <andy.weber.aw@gmail.com>
parents: 22220
diff changeset
39 ## @qcode{"png"}
a41c83fc601b dump_demos.m: Backout a8a9c275e12d and fix filesep on non-unix
Andreas Weber <andy.weber.aw@gmail.com>
parents: 22220
diff changeset
40 ## @end table
a41c83fc601b dump_demos.m: Backout a8a9c275e12d and fix filesep on non-unix
Andreas Weber <andy.weber.aw@gmail.com>
parents: 22220
diff changeset
41 ##
18874
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
42 ## For example, to produce PNG output for all demos of the functions
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
43 ## in the plot directory;
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
44 ##
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
45 ## @example
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
46 ## dump_demos plot dump.m png
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
47 ## @end example
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
48 ## @seealso{fntests, test, demo}
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
49 ## @end deftypefn
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
50
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
51 ## Author: Søren Hauberg <soren@hauberg.org>
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
52
22765
01aae08a0105 maint: Rename variables to match documentation in m-files.
Rik <rik@octave.org>
parents: 22755
diff changeset
53 function dump_demos (dirs={"plot/appearance", "plot/draw", "plot/util", "image"}, mfile="dump_plot_demos.m", fmt="png")
18875
0075f3fba930 dump_demos.m: Update to match new plot directory structure
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18874
diff changeset
54
22262
a41c83fc601b dump_demos.m: Backout a8a9c275e12d and fix filesep on non-unix
Andreas Weber <andy.weber.aw@gmail.com>
parents: 22220
diff changeset
55 if (nargin > 3)
18874
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
56 print_usage ();
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
57 endif
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
58
18895
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 18877
diff changeset
59 if (ischar (dirs))
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 18877
diff changeset
60 dirs = {dirs};
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 18877
diff changeset
61 elseif (! iscellstr (dirs))
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 18877
diff changeset
62 error ("dump_demos: DIRS must be a cell array of strings with directory names");
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 18877
diff changeset
63 endif
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 18877
diff changeset
64
22262
a41c83fc601b dump_demos.m: Backout a8a9c275e12d and fix filesep on non-unix
Andreas Weber <andy.weber.aw@gmail.com>
parents: 22220
diff changeset
65 if (! isunix ())
a41c83fc601b dump_demos.m: Backout a8a9c275e12d and fix filesep on non-unix
Andreas Weber <andy.weber.aw@gmail.com>
parents: 22220
diff changeset
66 dirs = strrep (dirs, "/", filesep ());
a41c83fc601b dump_demos.m: Backout a8a9c275e12d and fix filesep on non-unix
Andreas Weber <andy.weber.aw@gmail.com>
parents: 22220
diff changeset
67 endif
a41c83fc601b dump_demos.m: Backout a8a9c275e12d and fix filesep on non-unix
Andreas Weber <andy.weber.aw@gmail.com>
parents: 22220
diff changeset
68
22765
01aae08a0105 maint: Rename variables to match documentation in m-files.
Rik <rik@octave.org>
parents: 22755
diff changeset
69 [~, funcname, ext] = fileparts (mfile);
18895
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 18877
diff changeset
70 if (isempty (ext))
22765
01aae08a0105 maint: Rename variables to match documentation in m-files.
Rik <rik@octave.org>
parents: 22755
diff changeset
71 mfile = [mfile ".m"];
18874
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
72 endif
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
73
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
74 ## Create script beginning (close figures, etc.)
22765
01aae08a0105 maint: Rename variables to match documentation in m-files.
Rik <rik@octave.org>
parents: 22755
diff changeset
75 fid = fopen (mfile, "w");
18875
0075f3fba930 dump_demos.m: Update to match new plot directory structure
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18874
diff changeset
76 fprintf (fid, "%% DO NOT EDIT! Generated automatically by dump_demos.m\n");
18895
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 18877
diff changeset
77 fprintf (fid, "function %s ()\n", funcname);
22311
ee54a83a89ad dump_demos.m: Move demo outside try/catch and ctrl block (Matlab comp.)
Andreas Weber <andy.weber.aw@gmail.com>
parents: 22310
diff changeset
78 fprintf (fid, "set (0, 'DefaultAxesColorOrder', ...\n");
22302
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22262
diff changeset
79 fprintf (fid, " [ 0.00000 0.00000 1.00000 ;\n");
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22262
diff changeset
80 fprintf (fid, " 0.00000 0.50000 0.00000 ;\n");
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22262
diff changeset
81 fprintf (fid, " 1.00000 0.00000 0.00000 ;\n");
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22262
diff changeset
82 fprintf (fid, " 0.00000 0.75000 0.75000 ;\n");
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22262
diff changeset
83 fprintf (fid, " 0.75000 0.00000 0.75000 ;\n");
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22262
diff changeset
84 fprintf (fid, " 0.75000 0.75000 0.00000 ;\n");
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22262
diff changeset
85 fprintf (fid, " 0.25000 0.25000 0.25000 ]);\n");
18874
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
86 fprintf (fid, "close all\n");
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
87 fprintf (fid, "more off\n");
18925
87324260043d Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18897
diff changeset
88 fprintf (fid, "diary diary.log\n");
18874
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
89
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
90 ## Run and print the demos in each directory
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
91 for i = 1:numel (dirs)
18895
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 18877
diff changeset
92 d = dirs{i};
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 18877
diff changeset
93 if (! is_absolute_filename (d))
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 18877
diff changeset
94 d = dir_in_loadpath (d);
18875
0075f3fba930 dump_demos.m: Update to match new plot directory structure
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18874
diff changeset
95 endif
18895
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 18877
diff changeset
96 if (! exist (d, "dir"))
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 18877
diff changeset
97 error ("dump_demos: directory %s does not exist", d);
18875
0075f3fba930 dump_demos.m: Update to match new plot directory structure
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18874
diff changeset
98 endif
18874
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
99 dump_all_demos (d, fid, fmt);
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
100 endfor
18875
0075f3fba930 dump_demos.m: Update to match new plot directory structure
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18874
diff changeset
101
22151
283d8dfcad37 Make demos Matlab compatible for comparison with dump_demos script.
Rik <rik@octave.org>
parents: 22126
diff changeset
102 ## Add helper functions like sombrero
283d8dfcad37 Make demos Matlab compatible for comparison with dump_demos script.
Rik <rik@octave.org>
parents: 22126
diff changeset
103 dump_helper_fcns (fid);
283d8dfcad37 Make demos Matlab compatible for comparison with dump_demos script.
Rik <rik@octave.org>
parents: 22126
diff changeset
104
18925
87324260043d Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18897
diff changeset
105 ## Stop and flush diary
22151
283d8dfcad37 Make demos Matlab compatible for comparison with dump_demos script.
Rik <rik@octave.org>
parents: 22126
diff changeset
106 fprintf (fid, "\ndiary off\n");
18925
87324260043d Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18897
diff changeset
107
18874
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
108 ## Create script ending
22302
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22262
diff changeset
109 fprintf (fid, "end\n\n");
18874
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
110
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
111 ## Close script
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
112 fclose (fid);
21758
ffad2baa90f7 maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents: 20852
diff changeset
113
18874
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
114 endfunction
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
115
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
116 function dump_all_demos (directory, fid, fmt)
21758
ffad2baa90f7 maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents: 20852
diff changeset
117
18874
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
118 dirinfo = dir (fullfile (directory, "*.m"));
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
119 flist = {dirinfo.name};
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
120 ## Remove uigetdir, uigetfile, uiputfile, etc.
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
121 flist = flist(! strncmp (flist, "ui", 2));
18895
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 18877
diff changeset
122 ## Remove linkaxes, linkprops
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 18877
diff changeset
123 flist = flist(! strncmp (flist, "link", 4));
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 18877
diff changeset
124 ## Remove colormap
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 18877
diff changeset
125 flist = flist(! strncmp (flist, "colormap", 8));
18874
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
126 for i = 1:numel (flist)
18895
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 18877
diff changeset
127 fcn = flist{i};
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 18877
diff changeset
128 fcn(end-1:end) = []; # remove .m
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 18877
diff changeset
129 demos = get_demos (fcn);
18874
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
130 for d = 1:numel (demos)
18895
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 18877
diff changeset
131 idx = sprintf ("%02d", d);
18925
87324260043d Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18897
diff changeset
132 base_fn = sprintf ("%s_%s", fcn, idx);
18959
4c45986a278e dump_demos.m: Check if file exists before demo and add timing.
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18925
diff changeset
133 fn = sprintf ('%s.%s', base_fn, fmt);
22126
3f8ed6d7cb1c Improve plot comparison in sripts/testfun
Andreas Weber <andy.weber.aw@gmail.com>
parents: 21758
diff changeset
134 ## Wrap each demo in a function which create a local scope
3f8ed6d7cb1c Improve plot comparison in sripts/testfun
Andreas Weber <andy.weber.aw@gmail.com>
parents: 21758
diff changeset
135 ## to prevent that a previous demo overwrites i or pi, for example
3f8ed6d7cb1c Improve plot comparison in sripts/testfun
Andreas Weber <andy.weber.aw@gmail.com>
parents: 21758
diff changeset
136 fprintf (fid, "\nfunction %s ()\n", base_fn);
22311
ee54a83a89ad dump_demos.m: Move demo outside try/catch and ctrl block (Matlab comp.)
Andreas Weber <andy.weber.aw@gmail.com>
parents: 22310
diff changeset
137 fprintf (fid, " %s\n\n", demos{d});
ee54a83a89ad dump_demos.m: Move demo outside try/catch and ctrl block (Matlab comp.)
Andreas Weber <andy.weber.aw@gmail.com>
parents: 22310
diff changeset
138 fprintf (fid, "end\n\n");
ee54a83a89ad dump_demos.m: Move demo outside try/catch and ctrl block (Matlab comp.)
Andreas Weber <andy.weber.aw@gmail.com>
parents: 22310
diff changeset
139
ee54a83a89ad dump_demos.m: Move demo outside try/catch and ctrl block (Matlab comp.)
Andreas Weber <andy.weber.aw@gmail.com>
parents: 22310
diff changeset
140 fprintf (fid, "try\n");
18959
4c45986a278e dump_demos.m: Check if file exists before demo and add timing.
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18925
diff changeset
141 ## First check if the file already exists, skip demo if found
22311
ee54a83a89ad dump_demos.m: Move demo outside try/catch and ctrl block (Matlab comp.)
Andreas Weber <andy.weber.aw@gmail.com>
parents: 22310
diff changeset
142 fprintf (fid, " if (~ exist ('%s', 'file'))\n", fn);
19833
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19152
diff changeset
143 ## Invoke the ancient, deprecated random seed generators, but there is an
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19152
diff changeset
144 ## initialization mismatch with the more modern generators reported
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19152
diff changeset
145 ## here (https://savannah.gnu.org/bugs/?42557).
22126
3f8ed6d7cb1c Improve plot comparison in sripts/testfun
Andreas Weber <andy.weber.aw@gmail.com>
parents: 21758
diff changeset
146 fprintf (fid, " rand ('seed', 1);\n");
3f8ed6d7cb1c Improve plot comparison in sripts/testfun
Andreas Weber <andy.weber.aw@gmail.com>
parents: 21758
diff changeset
147 fprintf (fid, " tic ();\n");
22311
ee54a83a89ad dump_demos.m: Move demo outside try/catch and ctrl block (Matlab comp.)
Andreas Weber <andy.weber.aw@gmail.com>
parents: 22310
diff changeset
148 fprintf (fid, " %s ();\n", base_fn);
22126
3f8ed6d7cb1c Improve plot comparison in sripts/testfun
Andreas Weber <andy.weber.aw@gmail.com>
parents: 21758
diff changeset
149 fprintf (fid, " t_plot = toc ();\n");
3f8ed6d7cb1c Improve plot comparison in sripts/testfun
Andreas Weber <andy.weber.aw@gmail.com>
parents: 21758
diff changeset
150 fprintf (fid, " fig = (get (0, 'currentfigure'));\n");
3f8ed6d7cb1c Improve plot comparison in sripts/testfun
Andreas Weber <andy.weber.aw@gmail.com>
parents: 21758
diff changeset
151 fprintf (fid, " if (~ isempty (fig))\n");
3f8ed6d7cb1c Improve plot comparison in sripts/testfun
Andreas Weber <andy.weber.aw@gmail.com>
parents: 21758
diff changeset
152 fprintf (fid, " figure (fig);\n");
22311
ee54a83a89ad dump_demos.m: Move demo outside try/catch and ctrl block (Matlab comp.)
Andreas Weber <andy.weber.aw@gmail.com>
parents: 22310
diff changeset
153 fprintf (fid, " fprintf ('Printing ""%s"" ... ');\n", fn);
ee54a83a89ad dump_demos.m: Move demo outside try/catch and ctrl block (Matlab comp.)
Andreas Weber <andy.weber.aw@gmail.com>
parents: 22310
diff changeset
154 fprintf (fid, " tic ();\n");
ee54a83a89ad dump_demos.m: Move demo outside try/catch and ctrl block (Matlab comp.)
Andreas Weber <andy.weber.aw@gmail.com>
parents: 22310
diff changeset
155 fprintf (fid, " print ('-d%s', '%s');\n", fmt, fn);
ee54a83a89ad dump_demos.m: Move demo outside try/catch and ctrl block (Matlab comp.)
Andreas Weber <andy.weber.aw@gmail.com>
parents: 22310
diff changeset
156 fprintf (fid, " t_print = toc ();\n");
ee54a83a89ad dump_demos.m: Move demo outside try/catch and ctrl block (Matlab comp.)
Andreas Weber <andy.weber.aw@gmail.com>
parents: 22310
diff changeset
157 fprintf (fid, " fprintf ('[%%f %%f] done\\n',t_plot, t_print);\n");
22126
3f8ed6d7cb1c Improve plot comparison in sripts/testfun
Andreas Weber <andy.weber.aw@gmail.com>
parents: 21758
diff changeset
158 fprintf (fid, " end\n");
3f8ed6d7cb1c Improve plot comparison in sripts/testfun
Andreas Weber <andy.weber.aw@gmail.com>
parents: 21758
diff changeset
159 ## Temporary fix for cruft accumulating in figure window.
3f8ed6d7cb1c Improve plot comparison in sripts/testfun
Andreas Weber <andy.weber.aw@gmail.com>
parents: 21758
diff changeset
160 fprintf (fid, " close ('all');\n");
22311
ee54a83a89ad dump_demos.m: Move demo outside try/catch and ctrl block (Matlab comp.)
Andreas Weber <andy.weber.aw@gmail.com>
parents: 22310
diff changeset
161 fprintf (fid, " else\n");
ee54a83a89ad dump_demos.m: Move demo outside try/catch and ctrl block (Matlab comp.)
Andreas Weber <andy.weber.aw@gmail.com>
parents: 22310
diff changeset
162 fprintf (fid, " fprintf ('File ""%s"" already exists.\\n');\n", fn);
18874
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
163 fprintf (fid, " end\n");
22311
ee54a83a89ad dump_demos.m: Move demo outside try/catch and ctrl block (Matlab comp.)
Andreas Weber <andy.weber.aw@gmail.com>
parents: 22310
diff changeset
164 fprintf (fid, "catch\n");
ee54a83a89ad dump_demos.m: Move demo outside try/catch and ctrl block (Matlab comp.)
Andreas Weber <andy.weber.aw@gmail.com>
parents: 22310
diff changeset
165 fprintf (fid, " fprintf ('ERROR in %s: %%s\\n', lasterr ());\n", base_fn);
ee54a83a89ad dump_demos.m: Move demo outside try/catch and ctrl block (Matlab comp.)
Andreas Weber <andy.weber.aw@gmail.com>
parents: 22310
diff changeset
166 fprintf (fid, " err_fid = fopen ('%s.err', 'w');\n", base_fn);
ee54a83a89ad dump_demos.m: Move demo outside try/catch and ctrl block (Matlab comp.)
Andreas Weber <andy.weber.aw@gmail.com>
parents: 22310
diff changeset
167 fprintf (fid, " fprintf (err_fid, '%%s', lasterr ());\n");
ee54a83a89ad dump_demos.m: Move demo outside try/catch and ctrl block (Matlab comp.)
Andreas Weber <andy.weber.aw@gmail.com>
parents: 22310
diff changeset
168 fprintf (fid, " fclose (err_fid);\n");
22126
3f8ed6d7cb1c Improve plot comparison in sripts/testfun
Andreas Weber <andy.weber.aw@gmail.com>
parents: 21758
diff changeset
169 fprintf (fid, "end\n");
18874
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
170 endfor
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
171 endfor
22151
283d8dfcad37 Make demos Matlab compatible for comparison with dump_demos script.
Rik <rik@octave.org>
parents: 22126
diff changeset
172 fprintf (fid, "\nclose all\n");
21758
ffad2baa90f7 maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents: 20852
diff changeset
173
18874
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
174 endfunction
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
175
18895
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 18877
diff changeset
176 function retval = get_demos (fcn)
21758
ffad2baa90f7 maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents: 20852
diff changeset
177
18895
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 18877
diff changeset
178 [code, idx] = test (fcn, "grabdemo");
18874
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
179 num_demos = length (idx) - 1;
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
180 retval = cell (1, num_demos);
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
181 ## Now split the demos into a cell array
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
182 for k = 1:num_demos
18895
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 18877
diff changeset
183 retval{k} = oct2mat (code(idx(k):idx(k+1)-1));
18874
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
184 endfor
21758
ffad2baa90f7 maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents: 20852
diff changeset
185
18874
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
186 endfunction
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
187
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
188 function code = oct2mat (code)
21758
ffad2baa90f7 maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents: 20852
diff changeset
189
18874
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
190 ## Simple hacks to make things Matlab compatible
22302
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22262
diff changeset
191 code = strrep (code, "%!", "%%"); # system operator !
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22262
diff changeset
192 code = strrep (code, "!", "~"); # logical not operator
22189
829e0aafebdc dump_demos.m: Change regex for replacement of double quotes, add dummy assert
Andreas Weber <andy.weber.aw@gmail.com>
parents: 22151
diff changeset
193
18895
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 18877
diff changeset
194 ## Simply replacing double quotes with single quotes
22189
829e0aafebdc dump_demos.m: Change regex for replacement of double quotes, add dummy assert
Andreas Weber <andy.weber.aw@gmail.com>
parents: 22151
diff changeset
195 ## causes problems with strings like 'hello "world"' or transpose.
829e0aafebdc dump_demos.m: Change regex for replacement of double quotes, add dummy assert
Andreas Weber <andy.weber.aw@gmail.com>
parents: 22151
diff changeset
196
829e0aafebdc dump_demos.m: Change regex for replacement of double quotes, add dummy assert
Andreas Weber <andy.weber.aw@gmail.com>
parents: 22151
diff changeset
197 ## Test input for double quote replacement:
829e0aafebdc dump_demos.m: Change regex for replacement of double quotes, add dummy assert
Andreas Weber <andy.weber.aw@gmail.com>
parents: 22151
diff changeset
198 ## title ("bar");
829e0aafebdc dump_demos.m: Change regex for replacement of double quotes, add dummy assert
Andreas Weber <andy.weber.aw@gmail.com>
parents: 22151
diff changeset
199 ## a'
829e0aafebdc dump_demos.m: Change regex for replacement of double quotes, add dummy assert
Andreas Weber <andy.weber.aw@gmail.com>
parents: 22151
diff changeset
200 ## foo 'bar' "baz"
829e0aafebdc dump_demos.m: Change regex for replacement of double quotes, add dummy assert
Andreas Weber <andy.weber.aw@gmail.com>
parents: 22151
diff changeset
201 ## image (repmat ((1:64)', 1, 64));
829e0aafebdc dump_demos.m: Change regex for replacement of double quotes, add dummy assert
Andreas Weber <andy.weber.aw@gmail.com>
parents: 22151
diff changeset
202 ## fprintf ('File "brighten_01.png" already exists.\n');
829e0aafebdc dump_demos.m: Change regex for replacement of double quotes, add dummy assert
Andreas Weber <andy.weber.aw@gmail.com>
parents: 22151
diff changeset
203 ## title ({'x^2 + y^2'; 'plotted over circular disk with "circ"'});
829e0aafebdc dump_demos.m: Change regex for replacement of double quotes, add dummy assert
Andreas Weber <andy.weber.aw@gmail.com>
parents: 22151
diff changeset
204 ## annotation ('textbox', [0.1 0 0.8 1], 'string', ...
829e0aafebdc dump_demos.m: Change regex for replacement of double quotes, add dummy assert
Andreas Weber <andy.weber.aw@gmail.com>
parents: 22151
diff changeset
205 ## '"headstyle" property:', ...
829e0aafebdc dump_demos.m: Change regex for replacement of double quotes, add dummy assert
Andreas Weber <andy.weber.aw@gmail.com>
parents: 22151
diff changeset
206
829e0aafebdc dump_demos.m: Change regex for replacement of double quotes, add dummy assert
Andreas Weber <andy.weber.aw@gmail.com>
parents: 22151
diff changeset
207 code = regexprep (code, "[(,;\n][ ]*'[^']*'(*SKIP)(*F)|\"", "'",
18895
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 18877
diff changeset
208 "lineanchors", "dotexceptnewline");
22189
829e0aafebdc dump_demos.m: Change regex for replacement of double quotes, add dummy assert
Andreas Weber <andy.weber.aw@gmail.com>
parents: 22151
diff changeset
209
22316
b67a29a96056 dump_demos.m: Replace # not inside single quotes
Andreas Weber <andy.weber.aw@gmail.com>
parents: 22314
diff changeset
210 ## replace # not inside single quotes
b67a29a96056 dump_demos.m: Replace # not inside single quotes
Andreas Weber <andy.weber.aw@gmail.com>
parents: 22314
diff changeset
211 code = regexprep (code, "[(,;\n][ ]*'[^']*'(*SKIP)(*F)|#", "%");
22313
7cd75d61bbae dump_demos.m: Handle in-place operators like += for Matlab.
Rik <rik@octave.org>
parents: 22311
diff changeset
212
22302
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22262
diff changeset
213 ## Shorten all long forms of endXXX to 'end'
18895
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 18877
diff changeset
214 endkeywords = {"endfor", "endfunction", "endif", "endwhile", "end_try_catch"};
18874
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
215 for k = 1:numel (endkeywords)
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
216 code = strrep (code, endkeywords{k}, "end");
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
217 endfor
22302
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 22262
diff changeset
218 ## Comment keywords unknown to Matlab
18895
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 18877
diff changeset
219 commentkeywords = {"unwind_protect", "end_unwind_protect"};
18874
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
220 for k = 1:numel (commentkeywords)
18895
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 18877
diff changeset
221 code = strrep (code, commentkeywords{k}, ["%" commentkeywords{k}]);
18874
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
222 endfor
22313
7cd75d61bbae dump_demos.m: Handle in-place operators like += for Matlab.
Rik <rik@octave.org>
parents: 22311
diff changeset
223 ## Fix in-place operators
7cd75d61bbae dump_demos.m: Handle in-place operators like += for Matlab.
Rik <rik@octave.org>
parents: 22311
diff changeset
224 code = regexprep (code, '(\S+)(\s*)(.?[+-/*])=', '$1 = $1 $3');
22318
0e8c36397197 dump_demos.m: Replace 'x = y = XXX' and 'x = y = z = XXX' assignments.
Rik <rik@octave.org>
parents: 22316
diff changeset
225 ## Fix x = y = z = XXX assignment
0e8c36397197 dump_demos.m: Replace 'x = y = XXX' and 'x = y = z = XXX' assignments.
Rik <rik@octave.org>
parents: 22316
diff changeset
226 code = regexprep (code, '^\s*([^=\s]+)\s*=\s*([^=\s]+)\s*=\s*([^=\s]+)\s*=\s*([^=\n]+)$', ...
0e8c36397197 dump_demos.m: Replace 'x = y = XXX' and 'x = y = z = XXX' assignments.
Rik <rik@octave.org>
parents: 22316
diff changeset
227 "$1 = $4\n$2 = $4\n$3 = $4", "lineanchors");
0e8c36397197 dump_demos.m: Replace 'x = y = XXX' and 'x = y = z = XXX' assignments.
Rik <rik@octave.org>
parents: 22316
diff changeset
228 ## Fix x = y = XXX assignment
0e8c36397197 dump_demos.m: Replace 'x = y = XXX' and 'x = y = z = XXX' assignments.
Rik <rik@octave.org>
parents: 22316
diff changeset
229 code = regexprep (code, '^\s*([^=\s]+)\s*=\s*([^=\s]+)\s*=\s*([^=\n]+)$', ...
0e8c36397197 dump_demos.m: Replace 'x = y = XXX' and 'x = y = z = XXX' assignments.
Rik <rik@octave.org>
parents: 22316
diff changeset
230 "$1 = $3\n$2 = $3", "lineanchors");
18895
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 18877
diff changeset
231
18874
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
232 endfunction
18895
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 18877
diff changeset
233
22151
283d8dfcad37 Make demos Matlab compatible for comparison with dump_demos script.
Rik <rik@octave.org>
parents: 22126
diff changeset
234 function dump_helper_fcns (fid)
283d8dfcad37 Make demos Matlab compatible for comparison with dump_demos script.
Rik <rik@octave.org>
parents: 22126
diff changeset
235
283d8dfcad37 Make demos Matlab compatible for comparison with dump_demos script.
Rik <rik@octave.org>
parents: 22126
diff changeset
236 fprintf (fid, "\n%s\n", repmat ("%", [1, 60]));
283d8dfcad37 Make demos Matlab compatible for comparison with dump_demos script.
Rik <rik@octave.org>
parents: 22126
diff changeset
237 fdisp (fid, "% Helper functions");
283d8dfcad37 Make demos Matlab compatible for comparison with dump_demos script.
Rik <rik@octave.org>
parents: 22126
diff changeset
238 fprintf (fid, "%s\n", repmat ("%", [1, 60]));
283d8dfcad37 Make demos Matlab compatible for comparison with dump_demos script.
Rik <rik@octave.org>
parents: 22126
diff changeset
239
283d8dfcad37 Make demos Matlab compatible for comparison with dump_demos script.
Rik <rik@octave.org>
parents: 22126
diff changeset
240 ## Add sombrero function
283d8dfcad37 Make demos Matlab compatible for comparison with dump_demos script.
Rik <rik@octave.org>
parents: 22126
diff changeset
241 fdisp (fid, [
283d8dfcad37 Make demos Matlab compatible for comparison with dump_demos script.
Rik <rik@octave.org>
parents: 22126
diff changeset
242 "function [x, y, z] = sombrero (n) "
283d8dfcad37 Make demos Matlab compatible for comparison with dump_demos script.
Rik <rik@octave.org>
parents: 22126
diff changeset
243 " "
283d8dfcad37 Make demos Matlab compatible for comparison with dump_demos script.
Rik <rik@octave.org>
parents: 22126
diff changeset
244 " if (nargin == 0) "
283d8dfcad37 Make demos Matlab compatible for comparison with dump_demos script.
Rik <rik@octave.org>
parents: 22126
diff changeset
245 " n = 41; "
283d8dfcad37 Make demos Matlab compatible for comparison with dump_demos script.
Rik <rik@octave.org>
parents: 22126
diff changeset
246 " end "
283d8dfcad37 Make demos Matlab compatible for comparison with dump_demos script.
Rik <rik@octave.org>
parents: 22126
diff changeset
247 " "
283d8dfcad37 Make demos Matlab compatible for comparison with dump_demos script.
Rik <rik@octave.org>
parents: 22126
diff changeset
248 " [xx, yy] = meshgrid (linspace (-8, 8, n)); "
283d8dfcad37 Make demos Matlab compatible for comparison with dump_demos script.
Rik <rik@octave.org>
parents: 22126
diff changeset
249 " r = sqrt (xx.^2 + yy.^2) + eps; % eps prevents div/0 errors "
283d8dfcad37 Make demos Matlab compatible for comparison with dump_demos script.
Rik <rik@octave.org>
parents: 22126
diff changeset
250 " zz = sin (r) ./ r; "
283d8dfcad37 Make demos Matlab compatible for comparison with dump_demos script.
Rik <rik@octave.org>
parents: 22126
diff changeset
251 " "
283d8dfcad37 Make demos Matlab compatible for comparison with dump_demos script.
Rik <rik@octave.org>
parents: 22126
diff changeset
252 " if (nargout == 0) "
283d8dfcad37 Make demos Matlab compatible for comparison with dump_demos script.
Rik <rik@octave.org>
parents: 22126
diff changeset
253 " surf (xx, yy, zz); "
283d8dfcad37 Make demos Matlab compatible for comparison with dump_demos script.
Rik <rik@octave.org>
parents: 22126
diff changeset
254 " elseif (nargout == 1) "
283d8dfcad37 Make demos Matlab compatible for comparison with dump_demos script.
Rik <rik@octave.org>
parents: 22126
diff changeset
255 " x = zz; "
283d8dfcad37 Make demos Matlab compatible for comparison with dump_demos script.
Rik <rik@octave.org>
parents: 22126
diff changeset
256 " else "
283d8dfcad37 Make demos Matlab compatible for comparison with dump_demos script.
Rik <rik@octave.org>
parents: 22126
diff changeset
257 " x = xx; "
283d8dfcad37 Make demos Matlab compatible for comparison with dump_demos script.
Rik <rik@octave.org>
parents: 22126
diff changeset
258 " y = yy; "
283d8dfcad37 Make demos Matlab compatible for comparison with dump_demos script.
Rik <rik@octave.org>
parents: 22126
diff changeset
259 " z = zz; "
283d8dfcad37 Make demos Matlab compatible for comparison with dump_demos script.
Rik <rik@octave.org>
parents: 22126
diff changeset
260 " end "
283d8dfcad37 Make demos Matlab compatible for comparison with dump_demos script.
Rik <rik@octave.org>
parents: 22126
diff changeset
261 " "
283d8dfcad37 Make demos Matlab compatible for comparison with dump_demos script.
Rik <rik@octave.org>
parents: 22126
diff changeset
262 "end "
283d8dfcad37 Make demos Matlab compatible for comparison with dump_demos script.
Rik <rik@octave.org>
parents: 22126
diff changeset
263 ]); # End of sombrero dump
283d8dfcad37 Make demos Matlab compatible for comparison with dump_demos script.
Rik <rik@octave.org>
parents: 22126
diff changeset
264
283d8dfcad37 Make demos Matlab compatible for comparison with dump_demos script.
Rik <rik@octave.org>
parents: 22126
diff changeset
265 fprintf (fid, "\n");
283d8dfcad37 Make demos Matlab compatible for comparison with dump_demos script.
Rik <rik@octave.org>
parents: 22126
diff changeset
266
283d8dfcad37 Make demos Matlab compatible for comparison with dump_demos script.
Rik <rik@octave.org>
parents: 22126
diff changeset
267 ## Add rgbplot function
283d8dfcad37 Make demos Matlab compatible for comparison with dump_demos script.
Rik <rik@octave.org>
parents: 22126
diff changeset
268 fdisp (fid, [
283d8dfcad37 Make demos Matlab compatible for comparison with dump_demos script.
Rik <rik@octave.org>
parents: 22126
diff changeset
269 "function h = rgbplot (cmap, style) "
283d8dfcad37 Make demos Matlab compatible for comparison with dump_demos script.
Rik <rik@octave.org>
parents: 22126
diff changeset
270 " "
283d8dfcad37 Make demos Matlab compatible for comparison with dump_demos script.
Rik <rik@octave.org>
parents: 22126
diff changeset
271 " if (nargin == 1) "
283d8dfcad37 Make demos Matlab compatible for comparison with dump_demos script.
Rik <rik@octave.org>
parents: 22126
diff changeset
272 " style = 'profile'; "
283d8dfcad37 Make demos Matlab compatible for comparison with dump_demos script.
Rik <rik@octave.org>
parents: 22126
diff changeset
273 " end "
283d8dfcad37 Make demos Matlab compatible for comparison with dump_demos script.
Rik <rik@octave.org>
parents: 22126
diff changeset
274 " "
22338
e318739b0edd dump_demos.m: Make rgbplot Matlab compatible
Andreas Weber <andy.weber.aw@gmail.com>
parents: 22323
diff changeset
275 " idx = 1:size (cmap, 1); "
22151
283d8dfcad37 Make demos Matlab compatible for comparison with dump_demos script.
Rik <rik@octave.org>
parents: 22126
diff changeset
276 " switch (lower (style)) "
283d8dfcad37 Make demos Matlab compatible for comparison with dump_demos script.
Rik <rik@octave.org>
parents: 22126
diff changeset
277 " case 'profile' "
22338
e318739b0edd dump_demos.m: Make rgbplot Matlab compatible
Andreas Weber <andy.weber.aw@gmail.com>
parents: 22323
diff changeset
278 " htmp = plot (idx, cmap(:,1), 'r', ... "
e318739b0edd dump_demos.m: Make rgbplot Matlab compatible
Andreas Weber <andy.weber.aw@gmail.com>
parents: 22323
diff changeset
279 " idx, cmap(:,2), 'g', ... "
e318739b0edd dump_demos.m: Make rgbplot Matlab compatible
Andreas Weber <andy.weber.aw@gmail.com>
parents: 22323
diff changeset
280 " idx, cmap(:,3), 'b'); "
22151
283d8dfcad37 Make demos Matlab compatible for comparison with dump_demos script.
Rik <rik@octave.org>
parents: 22126
diff changeset
281 " set (gca (), 'ytick', 0:0.1:1); "
22310
b5ae7d55429c dump_demos.m: Replace rows with size ( ,1) for Matlab compatibility
Andreas Weber <andy.weber.aw@gmail.com>
parents: 22302
diff changeset
282 " set (gca (), 'xlim', [0 size(cmap,1)]); "
22151
283d8dfcad37 Make demos Matlab compatible for comparison with dump_demos script.
Rik <rik@octave.org>
parents: 22126
diff changeset
283 " case 'composite' "
22338
e318739b0edd dump_demos.m: Make rgbplot Matlab compatible
Andreas Weber <andy.weber.aw@gmail.com>
parents: 22323
diff changeset
284 " htmp = image (idx); "
22151
283d8dfcad37 Make demos Matlab compatible for comparison with dump_demos script.
Rik <rik@octave.org>
parents: 22126
diff changeset
285 " set (gca, 'ytick', []); "
283d8dfcad37 Make demos Matlab compatible for comparison with dump_demos script.
Rik <rik@octave.org>
parents: 22126
diff changeset
286 " colormap (cmap); "
283d8dfcad37 Make demos Matlab compatible for comparison with dump_demos script.
Rik <rik@octave.org>
parents: 22126
diff changeset
287 " end "
283d8dfcad37 Make demos Matlab compatible for comparison with dump_demos script.
Rik <rik@octave.org>
parents: 22126
diff changeset
288 " xlabel ('color index'); "
283d8dfcad37 Make demos Matlab compatible for comparison with dump_demos script.
Rik <rik@octave.org>
parents: 22126
diff changeset
289 " "
283d8dfcad37 Make demos Matlab compatible for comparison with dump_demos script.
Rik <rik@octave.org>
parents: 22126
diff changeset
290 " if (nargout > 0) "
283d8dfcad37 Make demos Matlab compatible for comparison with dump_demos script.
Rik <rik@octave.org>
parents: 22126
diff changeset
291 " h = htmp; "
283d8dfcad37 Make demos Matlab compatible for comparison with dump_demos script.
Rik <rik@octave.org>
parents: 22126
diff changeset
292 " end "
283d8dfcad37 Make demos Matlab compatible for comparison with dump_demos script.
Rik <rik@octave.org>
parents: 22126
diff changeset
293 " "
283d8dfcad37 Make demos Matlab compatible for comparison with dump_demos script.
Rik <rik@octave.org>
parents: 22126
diff changeset
294 "end "
283d8dfcad37 Make demos Matlab compatible for comparison with dump_demos script.
Rik <rik@octave.org>
parents: 22126
diff changeset
295 ]); # End of rgbplot dump
283d8dfcad37 Make demos Matlab compatible for comparison with dump_demos script.
Rik <rik@octave.org>
parents: 22126
diff changeset
296
22189
829e0aafebdc dump_demos.m: Change regex for replacement of double quotes, add dummy assert
Andreas Weber <andy.weber.aw@gmail.com>
parents: 22151
diff changeset
297 fprintf (fid, "\n");
829e0aafebdc dump_demos.m: Change regex for replacement of double quotes, add dummy assert
Andreas Weber <andy.weber.aw@gmail.com>
parents: 22151
diff changeset
298
829e0aafebdc dump_demos.m: Change regex for replacement of double quotes, add dummy assert
Andreas Weber <andy.weber.aw@gmail.com>
parents: 22151
diff changeset
299 fprintf (fid, "\n%s\n", repmat ("%", [1, 60]));
22151
283d8dfcad37 Make demos Matlab compatible for comparison with dump_demos script.
Rik <rik@octave.org>
parents: 22126
diff changeset
300
283d8dfcad37 Make demos Matlab compatible for comparison with dump_demos script.
Rik <rik@octave.org>
parents: 22126
diff changeset
301 endfunction
283d8dfcad37 Make demos Matlab compatible for comparison with dump_demos script.
Rik <rik@octave.org>
parents: 22126
diff changeset
302