annotate scripts/general/structfun.m @ 20158:7503499a252b stable

doc: Update docstrings to have one sentence summary as first line. Update scripts in audio, elfun, general, geometry, and image directories. * scripts/audio/@audioplayer/__get_properties__.m, scripts/audio/@audioplayer/audioplayer.m, scripts/audio/@audioplayer/get.m, scripts/audio/@audioplayer/isplaying.m, scripts/audio/@audioplayer/play.m, scripts/audio/@audioplayer/playblocking.m, scripts/audio/@audioplayer/set.m, scripts/audio/@audioplayer/subsasgn.m, scripts/audio/@audioplayer/subsref.m, scripts/audio/@audiorecorder/audiorecorder.m, scripts/audio/@audiorecorder/get.m, scripts/audio/@audiorecorder/getaudiodata.m, scripts/audio/@audiorecorder/getplayer.m, scripts/audio/@audiorecorder/isrecording.m, scripts/audio/@audiorecorder/play.m, scripts/audio/@audiorecorder/record.m, scripts/audio/@audiorecorder/recordblocking.m, scripts/audio/@audiorecorder/set.m, scripts/audio/@audiorecorder/stop.m, scripts/audio/@audiorecorder/subsasgn.m, scripts/audio/@audiorecorder/subsref.m, scripts/audio/lin2mu.m, scripts/audio/mu2lin.m, scripts/audio/record.m, scripts/audio/sound.m, scripts/audio/soundsc.m, scripts/audio/wavread.m, scripts/audio/wavwrite.m, scripts/elfun/cosd.m, scripts/elfun/sind.m, scripts/elfun/tand.m, scripts/general/accumarray.m, scripts/general/accumdim.m, scripts/general/bitcmp.m, scripts/general/bitget.m, scripts/general/bitset.m, scripts/general/blkdiag.m, scripts/general/cart2pol.m, scripts/general/cart2sph.m, scripts/general/cell2mat.m, scripts/general/celldisp.m, scripts/general/chop.m, scripts/general/circshift.m, scripts/general/common_size.m, scripts/general/cplxpair.m, scripts/general/cumtrapz.m, scripts/general/dblquad.m, scripts/general/deal.m, scripts/general/del2.m, scripts/general/display.m, scripts/general/divergence.m, scripts/general/fieldnames.m, scripts/general/flip.m, scripts/general/flipdim.m, scripts/general/fliplr.m, scripts/general/flipud.m, scripts/general/gradient.m, scripts/general/interp3.m, scripts/general/interpft.m, scripts/general/interpn.m, scripts/general/loadobj.m, scripts/general/logspace.m, scripts/general/methods.m, scripts/general/nargchk.m, scripts/general/narginchk.m, scripts/general/nargoutchk.m, scripts/general/nextpow2.m, scripts/general/nthargout.m, scripts/general/num2str.m, scripts/general/pol2cart.m, scripts/general/polyarea.m, scripts/general/postpad.m, scripts/general/prepad.m, scripts/general/profile.m, scripts/general/quadgk.m, scripts/general/quadl.m, scripts/general/quadv.m, scripts/general/randi.m, scripts/general/rat.m, scripts/general/repmat.m, scripts/general/rot90.m, scripts/general/rotdim.m, scripts/general/saveobj.m, scripts/general/shift.m, scripts/general/shiftdim.m, scripts/general/sortrows.m, scripts/general/sph2cart.m, scripts/general/structfun.m, scripts/general/subsindex.m, scripts/general/trapz.m, scripts/general/triplequad.m, scripts/geometry/delaunayn.m, scripts/geometry/dsearch.m, scripts/geometry/dsearchn.m, scripts/geometry/griddata.m, scripts/geometry/griddata3.m, scripts/geometry/griddatan.m, scripts/geometry/inpolygon.m, scripts/geometry/rectint.m, scripts/geometry/tsearchn.m, scripts/geometry/voronoi.m, scripts/geometry/voronoin.m, scripts/help/__unimplemented__.m, scripts/help/doc.m, scripts/help/doc_cache_create.m, scripts/help/get_first_help_sentence.m, scripts/help/help.m, scripts/help/lookfor.m, scripts/help/print_usage.m, scripts/help/type.m, scripts/help/which.m, scripts/image/autumn.m, scripts/image/bone.m, scripts/image/brighten.m, scripts/image/cmpermute.m, scripts/image/colorcube.m, scripts/image/contrast.m, scripts/image/cool.m, scripts/image/copper.m, scripts/image/cubehelix.m, scripts/image/flag.m, scripts/image/gmap40.m, scripts/image/gray.m, scripts/image/gray2ind.m, scripts/image/hot.m, scripts/image/hsv.m, scripts/image/image.m, scripts/image/imagesc.m, scripts/image/imfinfo.m, scripts/image/imformats.m, scripts/image/imread.m, scripts/image/imshow.m, scripts/image/imwrite.m, scripts/image/iscolormap.m, scripts/image/jet.m, scripts/image/lines.m, scripts/image/ntsc2rgb.m, scripts/image/ocean.m, scripts/image/pink.m, scripts/image/prism.m, scripts/image/rainbow.m, scripts/image/rgb2ntsc.m, scripts/image/spinmap.m, scripts/image/spring.m, scripts/image/summer.m, scripts/image/white.m, scripts/image/winter.m: Update docstrings to have one sentence summary as first line. Re-structure to have line lengths <= 80 chars.
author Rik <rik@octave.org>
date Sun, 03 May 2015 09:36:20 -0700
parents 9fc020886ae9
children 516bb87ea72e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
19697
4197fc428c7d maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
1 ## Copyright (C) 2007-2015 David Bateman
10132
aa0f575cf39b improve structfun's Matlab compatibility
Jaroslav Hajek <highegg@gmail.com>
parents: 10122
diff changeset
2 ## Copyright (C) 2010 VZLU Prague
6863
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
3 ##
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
4 ## This file is part of Octave.
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
5 ##
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
6 ## Octave is free software; you can redistribute it and/or modify it
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
7 ## 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: 7001
diff changeset
8 ## the Free Software Foundation; either version 3 of the License, or (at
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 7001
diff changeset
9 ## your option) any later version.
6863
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
10 ##
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
11 ## Octave is distributed in the hope that it will be useful, but
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
12 ## WITHOUT ANY WARRANTY; without even the implied warranty of
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
14 ## General Public License for more details.
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
15 ##
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
16 ## 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: 7001
diff changeset
17 ## along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 7001
diff changeset
18 ## <http://www.gnu.org/licenses/>.
6863
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
19
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
20 ## -*- texinfo -*-
11469
c776f063fefe Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents: 11190
diff changeset
21 ## @deftypefn {Function File} {} structfun (@var{func}, @var{S})
11471
994e2a93a8e2 Use uppercase 'A' to refer to matrix inputs in m-files.
Rik <octave@nomad.inbox5.com>
parents: 11469
diff changeset
22 ## @deftypefnx {Function File} {[@var{A}, @dots{}] =} structfun (@dots{})
8507
cadc73247d65 style fixes
John W. Eaton <jwe@octave.org>
parents: 8347
diff changeset
23 ## @deftypefnx {Function File} {} structfun (@dots{}, "ErrorHandler", @var{errfunc})
cadc73247d65 style fixes
John W. Eaton <jwe@octave.org>
parents: 8347
diff changeset
24 ## @deftypefnx {Function File} {} structfun (@dots{}, "UniformOutput", @var{val})
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
25 ##
6863
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
26 ## Evaluate the function named @var{name} on the fields of the structure
11469
c776f063fefe Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents: 11190
diff changeset
27 ## @var{S}. The fields of @var{S} are passed to the function @var{func}
6863
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
28 ## individually.
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
29 ##
20158
7503499a252b doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19833
diff changeset
30 ## @code{structfun} accepts an arbitrary function @var{func} in the form of an
7503499a252b doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19833
diff changeset
31 ## inline function, function handle, or the name of a function (in a character
7503499a252b doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19833
diff changeset
32 ## string). In the case of a character string argument, the function must
7503499a252b doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19833
diff changeset
33 ## accept a single argument named @var{x}, and it must return a string value.
7503499a252b doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19833
diff changeset
34 ## If the function returns more than one argument, they are returned as
7503499a252b doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19833
diff changeset
35 ## separate output variables.
6863
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
36 ##
20158
7503499a252b doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19833
diff changeset
37 ## If the parameter @qcode{"UniformOutput"} is set to true (the default), then
7503499a252b doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19833
diff changeset
38 ## the function must return a single element which will be concatenated into
7503499a252b doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19833
diff changeset
39 ## the return value. If @qcode{"UniformOutput"} is false, the outputs are
7503499a252b doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19833
diff changeset
40 ## placed into a structure with the same fieldnames as the input structure.
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
41 ##
6863
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
42 ## @example
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
43 ## @group
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
44 ## s.name1 = "John Smith";
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
45 ## s.name2 = "Jill Jones";
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
46 ## structfun (@@(x) regexp (x, '(\w+)$', "matches")@{1@}, s,
8507
cadc73247d65 style fixes
John W. Eaton <jwe@octave.org>
parents: 8347
diff changeset
47 ## "UniformOutput", false)
14327
4d917a6a858b doc: Use Octave coding conventions in @example blocks of docstrings.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
48 ## @result{}
10122
9d1a14e12431 Update docs and add tests for container functions
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9036
diff changeset
49 ## @{
9d1a14e12431 Update docs and add tests for container functions
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9036
diff changeset
50 ## name1 = Smith
9d1a14e12431 Update docs and add tests for container functions
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9036
diff changeset
51 ## name2 = Jones
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
52 ## @}
6863
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
53 ## @end group
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
54 ## @end example
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
55 ##
20158
7503499a252b doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19833
diff changeset
56 ## Given the parameter @qcode{"ErrorHandler"}, @var{errfunc} defines a function
7503499a252b doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19833
diff changeset
57 ## to call in case @var{func} generates an error. The form of the function is
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
58 ##
6863
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
59 ## @example
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
60 ## function [@dots{}] = errfunc (@var{se}, @dots{})
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
61 ## @end example
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
62 ##
10846
a4f482e66b65 Grammarcheck more of the documentation.
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
63 ## @noindent
6863
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
64 ## where there is an additional input argument to @var{errfunc} relative to
16826
a4969508008e doc: Periodic spellcheck of the documentation.
Rik <rik@octave.org>
parents: 16772
diff changeset
65 ## @var{func}, given by @nospell{@var{se}}. This is a structure with the
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17097
diff changeset
66 ## elements @qcode{"identifier"}, @qcode{"message"} and @qcode{"index"},
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17097
diff changeset
67 ## giving respectively the error identifier, the error message, and the index
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17097
diff changeset
68 ## into the input arguments of the element that caused the error. For an
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17097
diff changeset
69 ## example on how to use an error handler, @pxref{XREFcellfun,,cellfun}.
10122
9d1a14e12431 Update docs and add tests for container functions
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9036
diff changeset
70 ##
10687
a8ce6bdecce5 Improve documentation strings.
Rik <octave@nomad.inbox5.com>
parents: 10549
diff changeset
71 ## @seealso{cellfun, arrayfun, spfun}
6863
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
72 ## @end deftypefn
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
73
11469
c776f063fefe Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents: 11190
diff changeset
74 function varargout = structfun (func, S, varargin);
10134
be13fa20656a error on invalid opts in structfun
Jaroslav Hajek <highegg@gmail.com>
parents: 10132
diff changeset
75
6863
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
76 if (nargin < 2)
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
77 print_usage ();
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
78 endif
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
79
10134
be13fa20656a error on invalid opts in structfun
Jaroslav Hajek <highegg@gmail.com>
parents: 10132
diff changeset
80 nargs = length (varargin);
be13fa20656a error on invalid opts in structfun
Jaroslav Hajek <highegg@gmail.com>
parents: 10132
diff changeset
81
be13fa20656a error on invalid opts in structfun
Jaroslav Hajek <highegg@gmail.com>
parents: 10132
diff changeset
82 recognized_opts = {"UniformOutput", "ErrorHandler"};
be13fa20656a error on invalid opts in structfun
Jaroslav Hajek <highegg@gmail.com>
parents: 10132
diff changeset
83 uo_str = recognized_opts{1};
be13fa20656a error on invalid opts in structfun
Jaroslav Hajek <highegg@gmail.com>
parents: 10132
diff changeset
84
10132
aa0f575cf39b improve structfun's Matlab compatibility
Jaroslav Hajek <highegg@gmail.com>
parents: 10122
diff changeset
85 uniform_output = true;
aa0f575cf39b improve structfun's Matlab compatibility
Jaroslav Hajek <highegg@gmail.com>
parents: 10122
diff changeset
86
10134
be13fa20656a error on invalid opts in structfun
Jaroslav Hajek <highegg@gmail.com>
parents: 10132
diff changeset
87 while (nargs >= 2)
be13fa20656a error on invalid opts in structfun
Jaroslav Hajek <highegg@gmail.com>
parents: 10132
diff changeset
88 opt_match = strcmpi (varargin{nargs-1}, recognized_opts);
be13fa20656a error on invalid opts in structfun
Jaroslav Hajek <highegg@gmail.com>
parents: 10132
diff changeset
89 if (opt_match(1))
be13fa20656a error on invalid opts in structfun
Jaroslav Hajek <highegg@gmail.com>
parents: 10132
diff changeset
90 uniform_output = varargin{nargs};
be13fa20656a error on invalid opts in structfun
Jaroslav Hajek <highegg@gmail.com>
parents: 10132
diff changeset
91 endif
be13fa20656a error on invalid opts in structfun
Jaroslav Hajek <highegg@gmail.com>
parents: 10132
diff changeset
92 if (any (opt_match))
be13fa20656a error on invalid opts in structfun
Jaroslav Hajek <highegg@gmail.com>
parents: 10132
diff changeset
93 nargs -= 2;
be13fa20656a error on invalid opts in structfun
Jaroslav Hajek <highegg@gmail.com>
parents: 10132
diff changeset
94 else
be13fa20656a error on invalid opts in structfun
Jaroslav Hajek <highegg@gmail.com>
parents: 10132
diff changeset
95 break;
be13fa20656a error on invalid opts in structfun
Jaroslav Hajek <highegg@gmail.com>
parents: 10132
diff changeset
96 endif
be13fa20656a error on invalid opts in structfun
Jaroslav Hajek <highegg@gmail.com>
parents: 10132
diff changeset
97 endwhile
be13fa20656a error on invalid opts in structfun
Jaroslav Hajek <highegg@gmail.com>
parents: 10132
diff changeset
98
be13fa20656a error on invalid opts in structfun
Jaroslav Hajek <highegg@gmail.com>
parents: 10132
diff changeset
99 if (nargs > 0)
be13fa20656a error on invalid opts in structfun
Jaroslav Hajek <highegg@gmail.com>
parents: 10132
diff changeset
100 error ("structfun: invalid options");
10132
aa0f575cf39b improve structfun's Matlab compatibility
Jaroslav Hajek <highegg@gmail.com>
parents: 10122
diff changeset
101 endif
aa0f575cf39b improve structfun's Matlab compatibility
Jaroslav Hajek <highegg@gmail.com>
parents: 10122
diff changeset
102
6863
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
103 varargout = cell (max ([nargout, 1]), 1);
11469
c776f063fefe Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents: 11190
diff changeset
104 [varargout{:}] = cellfun (func, struct2cell (S), varargin{:});
6863
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
105
10132
aa0f575cf39b improve structfun's Matlab compatibility
Jaroslav Hajek <highegg@gmail.com>
parents: 10122
diff changeset
106 if (! uniform_output)
19833
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19697
diff changeset
107 varargout = cellfun ("cell2struct", varargout, {fieldnames(S)}, {1}, ...
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19697
diff changeset
108 uo_str, false);
6863
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
109 endif
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
110 endfunction
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
111
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
112
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
113 %!test
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
114 %! s.name1 = "John Smith";
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
115 %! s.name2 = "Jill Jones";
6863
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
116 %! l.name1 = "Smith";
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
117 %! l.name2 = "Jones";
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
118 %! o = structfun (@(x) regexp (x, '(\w+)$', "matches"){1}, s,
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10134
diff changeset
119 %! "UniformOutput", false);
6863
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
120 %! assert (o, l);
10132
aa0f575cf39b improve structfun's Matlab compatibility
Jaroslav Hajek <highegg@gmail.com>
parents: 10122
diff changeset
121
13305
63463570d9fe Add %!endfunction block keyword to test.m
Rik <octave@nomad.inbox5.com>
parents: 12931
diff changeset
122 %!function [a, b] = __twoouts (x)
10132
aa0f575cf39b improve structfun's Matlab compatibility
Jaroslav Hajek <highegg@gmail.com>
parents: 10122
diff changeset
123 %! a = x + x;
aa0f575cf39b improve structfun's Matlab compatibility
Jaroslav Hajek <highegg@gmail.com>
parents: 10122
diff changeset
124 %! b = x * x;
13305
63463570d9fe Add %!endfunction block keyword to test.m
Rik <octave@nomad.inbox5.com>
parents: 12931
diff changeset
125 %!endfunction
10132
aa0f575cf39b improve structfun's Matlab compatibility
Jaroslav Hajek <highegg@gmail.com>
parents: 10122
diff changeset
126
aa0f575cf39b improve structfun's Matlab compatibility
Jaroslav Hajek <highegg@gmail.com>
parents: 10122
diff changeset
127 %!test
aa0f575cf39b improve structfun's Matlab compatibility
Jaroslav Hajek <highegg@gmail.com>
parents: 10122
diff changeset
128 %! s = struct ("a", {1, 2, 3}, "b", {4, 5, 6});
aa0f575cf39b improve structfun's Matlab compatibility
Jaroslav Hajek <highegg@gmail.com>
parents: 10122
diff changeset
129 %! c(1:2, 1, 1) = [2; 8];
aa0f575cf39b improve structfun's Matlab compatibility
Jaroslav Hajek <highegg@gmail.com>
parents: 10122
diff changeset
130 %! c(1:2, 1, 2) = [4; 10];
aa0f575cf39b improve structfun's Matlab compatibility
Jaroslav Hajek <highegg@gmail.com>
parents: 10122
diff changeset
131 %! c(1:2, 1, 3) = [6; 12];
aa0f575cf39b improve structfun's Matlab compatibility
Jaroslav Hajek <highegg@gmail.com>
parents: 10122
diff changeset
132 %! d(1:2, 1, 1) = [1; 16];
aa0f575cf39b improve structfun's Matlab compatibility
Jaroslav Hajek <highegg@gmail.com>
parents: 10122
diff changeset
133 %! d(1:2, 1, 2) = [4; 25];
aa0f575cf39b improve structfun's Matlab compatibility
Jaroslav Hajek <highegg@gmail.com>
parents: 10122
diff changeset
134 %! d(1:2, 1, 3) = [9; 36];
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14327
diff changeset
135 %! [aa, bb] = structfun (@__twoouts, s);
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14327
diff changeset
136 %! assert (aa, c);
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14327
diff changeset
137 %! assert (bb, d);
10132
aa0f575cf39b improve structfun's Matlab compatibility
Jaroslav Hajek <highegg@gmail.com>
parents: 10122
diff changeset
138
aa0f575cf39b improve structfun's Matlab compatibility
Jaroslav Hajek <highegg@gmail.com>
parents: 10122
diff changeset
139 %!test
aa0f575cf39b improve structfun's Matlab compatibility
Jaroslav Hajek <highegg@gmail.com>
parents: 10122
diff changeset
140 %! s = struct ("a", {1, 2, 3}, "b", {4, 5, 6});
aa0f575cf39b improve structfun's Matlab compatibility
Jaroslav Hajek <highegg@gmail.com>
parents: 10122
diff changeset
141 %! c = struct ("a", {2, 4, 6}, "b", {8, 10, 12});
aa0f575cf39b improve structfun's Matlab compatibility
Jaroslav Hajek <highegg@gmail.com>
parents: 10122
diff changeset
142 %! d = struct ("a", {1, 4, 9}, "b", {16, 25, 36});
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14327
diff changeset
143 %! [aa, bb] = structfun (@__twoouts, s, "UniformOutput", false);
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14327
diff changeset
144 %! assert (aa, c);
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14327
diff changeset
145 %! assert (bb, d);
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14327
diff changeset
146