annotate scripts/general/celldisp.m @ 14237:11949c9795a0

Revamp %!demos in m-files to use Octave coding conventions on spacing, etc. Add clf() to all demos using plot features to get reproducibility. Use 64 as input to all colormaps (jet (64)) to get reproducibility. * bicubic.m, cell2mat.m, celldisp.m, cplxpair.m, interp1.m, interp2.m, interpft.m, interpn.m, profile.m, profshow.m, convhull.m, delaunay.m, griddata.m, inpolygon.m, voronoi.m, autumn.m, bone.m, contrast.m, cool.m, copper.m, flag.m, gmap40.m, gray.m, hot.m, hsv.m, image.m, imshow.m, jet.m, ocean.m, pink.m, prism.m, rainbow.m, spring.m, summer.m, white.m, winter.m, condest.m, onenormest.m, axis.m, clabel.m, colorbar.m, comet.m, comet3.m, compass.m, contour.m, contour3.m, contourf.m, cylinder.m, daspect.m, ellipsoid.m, errorbar.m, ezcontour.m, ezcontourf.m, ezmesh.m, ezmeshc.m, ezplot.m, ezplot3.m, ezpolar.m, ezsurf.m, ezsurfc.m, feather.m, fill.m, fplot.m, grid.m, hold.m, isosurface.m, legend.m, loglog.m, loglogerr.m, pareto.m, patch.m, pbaspect.m, pcolor.m, pie.m, pie3.m, plot3.m, plotmatrix.m, plotyy.m, polar.m, quiver.m, quiver3.m, rectangle.m, refreshdata.m, ribbon.m, rose.m, scatter.m, scatter3.m, semilogx.m, semilogxerr.m, semilogy.m, semilogyerr.m, shading.m, slice.m, sombrero.m, stairs.m, stem.m, stem3.m, subplot.m, surf.m, surfc.m, surfl.m, surfnorm.m, text.m, title.m, trimesh.m, triplot.m, trisurf.m, uigetdir.m, uigetfile.m, uimenu.m, uiputfile.m, waitbar.m, xlim.m, ylim.m, zlim.m, mkpp.m, pchip.m, polyaffine.m, spline.m, bicgstab.m, cgs.m, gplot.m, pcg.m, pcr.m, treeplot.m, strtok.m, demo.m, example.m, rundemos.m, speed.m, test.m, calendar.m, datestr.m, datetick.m, weekday.m: Revamp %!demos to use Octave coding conventions on spacing, etc.
author Rik <octave@nomad.inbox5.com>
date Fri, 20 Jan 2012 12:59:53 -0800
parents 72c96de7a403
children ce2b59a6d0e5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
14138
72c96de7a403 maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents: 13046
diff changeset
1 ## Copyright (C) 2007-2012 David Bateman
6869
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
2 ##
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
3 ## This file is part of Octave.
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
4 ##
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
6 ## under the terms of the GNU General Public License as published by
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6869
diff changeset
7 ## the Free Software Foundation; either version 3 of the License, or (at
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6869
diff changeset
8 ## your option) any later version.
6869
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
9 ##
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
13 ## General Public License for more details.
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
14 ##
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
15 ## You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6869
diff changeset
16 ## along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6869
diff changeset
17 ## <http://www.gnu.org/licenses/>.
6869
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
18
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
19 ## -*- texinfo -*-
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
20 ## @deftypefn {Function File} {} celldisp (@var{c}, @var{name})
9036
58604c45ca74 Cleanup of data types related documentation
Rik <rdrider0-list@yahoo.com>
parents: 7017
diff changeset
21 ## Recursively display the contents of a cell array. By default the values
58604c45ca74 Cleanup of data types related documentation
Rik <rdrider0-list@yahoo.com>
parents: 7017
diff changeset
22 ## are displayed with the name of the variable @var{c}. However, this name
10122
9d1a14e12431 Update docs and add tests for container functions
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9245
diff changeset
23 ## can be replaced with the variable @var{name}. For example:
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
24 ##
10122
9d1a14e12431 Update docs and add tests for container functions
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9245
diff changeset
25 ## @example
9d1a14e12431 Update docs and add tests for container functions
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9245
diff changeset
26 ## @group
9d1a14e12431 Update docs and add tests for container functions
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9245
diff changeset
27 ## c = @{1, 2, @{31, 32@}@};
9d1a14e12431 Update docs and add tests for container functions
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9245
diff changeset
28 ## celldisp(c, "b")
9d1a14e12431 Update docs and add tests for container functions
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9245
diff changeset
29 ## @result{}
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
30 ## b@{1@} =
10122
9d1a14e12431 Update docs and add tests for container functions
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9245
diff changeset
31 ## 1
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
32 ## b@{2@} =
10122
9d1a14e12431 Update docs and add tests for container functions
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9245
diff changeset
33 ## 2
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
34 ## b@{3@}@{1@} =
10122
9d1a14e12431 Update docs and add tests for container functions
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9245
diff changeset
35 ## 31
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
36 ## b@{3@}@{2@} =
10122
9d1a14e12431 Update docs and add tests for container functions
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9245
diff changeset
37 ## 32
9d1a14e12431 Update docs and add tests for container functions
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9245
diff changeset
38 ## @end group
9d1a14e12431 Update docs and add tests for container functions
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9245
diff changeset
39 ## @end example
9d1a14e12431 Update docs and add tests for container functions
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9245
diff changeset
40 ##
6869
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
41 ## @seealso{disp}
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
42 ## @end deftypefn
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
43
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
44 ## This is ugly, but seems to be what matlab does..
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
45
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
46 function celldisp (c, name)
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
47 if (nargin < 1 || nargin > 2)
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
48 print_usage ();
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
49 endif
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
50
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
51 if (! iscell (c))
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
52 error ("celldisp: argument must be a cell array");
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
53 endif
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
54
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
55 if (nargin == 1)
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
56 name = inputname (1);
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
57 endif
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
58
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
59 for i = 1: numel (c)
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
60 if (iscell (c{i}))
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
61 celldisp (c{i}, sprintf ("%s{%s}", name, indices (size (c), i)));
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
62 else
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
63 disp (sprintf ("%s{%s} = \n", name, indices (size (c), i)));
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
64 disp (c{i});
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
65 disp ("");
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
66 endif
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
67 endfor
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
68 endfunction
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
69
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
70 function s = indices (dv, i)
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
71 if (sum (dv != 1) > 1)
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
72 c = cell (size (dv));
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
73 [c{:}] = ind2sub (dv, i);
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
74 s = sprintf("%i,", c{:});
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
75 s(end) = [];
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
76 else
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
77 s = sprintf("%i", i);
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
78 endif
f9c893831e68 [project @ 2007-09-06 16:38:44 by dbateman]
dbateman
parents:
diff changeset
79 endfunction
10122
9d1a14e12431 Update docs and add tests for container functions
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9245
diff changeset
80
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
81
10122
9d1a14e12431 Update docs and add tests for container functions
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9245
diff changeset
82 %!demo
9d1a14e12431 Update docs and add tests for container functions
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9245
diff changeset
83 %! c = {1, 2, {31, 32}};
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
84 %! celldisp (c, "b")
13046
b2aca5ac54a2 codesprint: argument checking tests for celldisp
John W. Eaton <jwe@octave.org>
parents: 11587
diff changeset
85
b2aca5ac54a2 codesprint: argument checking tests for celldisp
John W. Eaton <jwe@octave.org>
parents: 11587
diff changeset
86 %!error celldisp ();
b2aca5ac54a2 codesprint: argument checking tests for celldisp
John W. Eaton <jwe@octave.org>
parents: 11587
diff changeset
87 %!error celldisp ({}, "name", 1);
b2aca5ac54a2 codesprint: argument checking tests for celldisp
John W. Eaton <jwe@octave.org>
parents: 11587
diff changeset
88 %!error celldisp (1);