annotate scripts/general/structfun.m @ 30893:e1788b1a315f

maint: Use "fcn" as preferred abbreviation for "function" in m-files. * accumarray.m, accumdim.m, quadl.m, quadv.m, randi.m, structfun.m, __is_function__.m, uigetfile.m, uimenu.m, uiputfile.m, doc_cache_create.m, colorspace_conversion_input_check.m, imageIO.m, argnames.m, vectorize.m, vectorize.m, normest1.m, inputname.m, nthargout.m, display_info_file.m, decic.m, ode15i.m, ode15s.m, ode23.m, ode23s.m, ode45.m, odeset.m, check_default_input.m, integrate_adaptive.m, ode_event_handler.m, runge_kutta_23.m, runge_kutta_23s.m, runge_kutta_45_dorpri.m, runge_kutta_interpolate.m, starting_stepsize.m, __all_opts__.m, fminbnd.m, fminsearch.m, fminunc.m, fsolve.m, fzero.m, sqp.m, fplot.m, plotyy.m, __bar__.m, __ezplot__.m, flat_entry.html, profexport.m, movfun.m, bicg.m, bicgstab.m, cgs.m, eigs.m, gmres.m, pcg.m, __alltohandles__.m, __sprand__.m, qmr.m, tfqmr.m, dump_demos.m: Replace "func", "fun", "fn" in documentation and variable names with "fcn".
author Rik <rik@octave.org>
date Mon, 04 Apr 2022 18:14:56 -0700
parents 5d3faba0342e
children 597f3ee61a48
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
1 ########################################################################
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
2 ##
30564
796f54d4ddbf update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
3 ## Copyright (C) 2007-2022 The Octave Project Developers
27918
b442ec6dda5c use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents: 26600
diff changeset
4 ##
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
5 ## See the file COPYRIGHT.md in the top-level directory of this
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
6 ## distribution or <https://octave.org/copyright/>.
6863
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
7 ##
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
8 ## This file is part of Octave.
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
9 ##
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 23220
diff changeset
10 ## Octave is free software: you can redistribute it and/or modify it
6863
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
11 ## under the terms of the GNU General Public License as published by
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 23220
diff changeset
12 ## the Free Software Foundation, either version 3 of the License, or
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22627
diff changeset
13 ## (at your option) any later version.
6863
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
14 ##
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
15 ## 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
16 ## WITHOUT ANY WARRANTY; without even the implied warranty of
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22627
diff changeset
17 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22627
diff changeset
18 ## GNU General Public License for more details.
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 ## 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
21 ## along with Octave; see the file COPYING. If not, see
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 23220
diff changeset
22 ## <https://www.gnu.org/licenses/>.
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
23 ##
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
24 ########################################################################
6863
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
25
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
26 ## -*- texinfo -*-
30893
e1788b1a315f maint: Use "fcn" as preferred abbreviation for "function" in m-files.
Rik <rik@octave.org>
parents: 30875
diff changeset
27 ## @deftypefn {} {@var{A} =} structfun (@var{fcn}, @var{S})
e1788b1a315f maint: Use "fcn" as preferred abbreviation for "function" in m-files.
Rik <rik@octave.org>
parents: 30875
diff changeset
28 ## @deftypefnx {} {@var{A} =} structfun (@dots{}, "ErrorHandler", @var{errfcn})
30875
5d3faba0342e doc: Ensure documentation lists output argument when it exists for all m-files.
Rik <rik@octave.org>
parents: 30564
diff changeset
29 ## @deftypefnx {} {@var{A} =} structfun (@dots{}, "UniformOutput", @var{val})
5d3faba0342e doc: Ensure documentation lists output argument when it exists for all m-files.
Rik <rik@octave.org>
parents: 30564
diff changeset
30 ## @deftypefnx {} {[@var{A}, @var{B}, @dots{}] =} structfun (@dots{})
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
31 ##
6863
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
32 ## Evaluate the function named @var{name} on the fields of the structure
30893
e1788b1a315f maint: Use "fcn" as preferred abbreviation for "function" in m-files.
Rik <rik@octave.org>
parents: 30875
diff changeset
33 ## @var{S}. The fields of @var{S} are passed to the function @var{fcn}
6863
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
34 ## individually.
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
35 ##
30893
e1788b1a315f maint: Use "fcn" as preferred abbreviation for "function" in m-files.
Rik <rik@octave.org>
parents: 30875
diff changeset
36 ## @code{structfun} accepts an arbitrary function @var{fcn} in the form of an
20158
7503499a252b doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19833
diff changeset
37 ## 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
38 ## 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
39 ## 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
40 ## 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
41 ## separate output variables.
6863
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
42 ##
20158
7503499a252b doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19833
diff changeset
43 ## 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
44 ## 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
45 ## 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
46 ## 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
47 ##
6863
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
48 ## @example
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
49 ## @group
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
50 ## s.name1 = "John Smith";
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
51 ## s.name2 = "Jill Jones";
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
52 ## structfun (@@(x) regexp (x, '(\w+)$', "matches")@{1@}, s,
8507
cadc73247d65 style fixes
John W. Eaton <jwe@octave.org>
parents: 8347
diff changeset
53 ## "UniformOutput", false)
26600
f6730533820e doc: clean up doc example blocks for accuracy and consistent formatting
Mike Miller <mtmiller@octave.org>
parents: 26376
diff changeset
54 ## @result{} scalar structure containing the fields:
f6730533820e doc: clean up doc example blocks for accuracy and consistent formatting
Mike Miller <mtmiller@octave.org>
parents: 26376
diff changeset
55 ## name1 = Smith
f6730533820e doc: clean up doc example blocks for accuracy and consistent formatting
Mike Miller <mtmiller@octave.org>
parents: 26376
diff changeset
56 ## name2 = Jones
6863
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
57 ## @end group
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
58 ## @end example
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
59 ##
30893
e1788b1a315f maint: Use "fcn" as preferred abbreviation for "function" in m-files.
Rik <rik@octave.org>
parents: 30875
diff changeset
60 ## Given the parameter @qcode{"ErrorHandler"}, @var{errfcn} defines a function
e1788b1a315f maint: Use "fcn" as preferred abbreviation for "function" in m-files.
Rik <rik@octave.org>
parents: 30875
diff changeset
61 ## to call in case @var{fcn} 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
62 ##
6863
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
63 ## @example
30893
e1788b1a315f maint: Use "fcn" as preferred abbreviation for "function" in m-files.
Rik <rik@octave.org>
parents: 30875
diff changeset
64 ## function [@dots{}] = errfcn (@var{se}, @dots{})
6863
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
65 ## @end example
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
66 ##
10846
a4f482e66b65 Grammarcheck more of the documentation.
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
67 ## @noindent
30893
e1788b1a315f maint: Use "fcn" as preferred abbreviation for "function" in m-files.
Rik <rik@octave.org>
parents: 30875
diff changeset
68 ## where there is an additional input argument to @var{errfcn} relative to
e1788b1a315f maint: Use "fcn" as preferred abbreviation for "function" in m-files.
Rik <rik@octave.org>
parents: 30875
diff changeset
69 ## @var{fcn}, 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
70 ## 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
71 ## 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
72 ## into the input arguments of the element that caused the error. For an
28959
5394d688d456 doc: Use @code{} within alternate text for @xref,@pxref macros for better Info display.
Rik <rik@octave.org>
parents: 27923
diff changeset
73 ## example on how to use an error handler, @pxref{XREFcellfun,,@code{cellfun}}.
10122
9d1a14e12431 Update docs and add tests for container functions
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9036
diff changeset
74 ##
10687
a8ce6bdecce5 Improve documentation strings.
Rik <octave@nomad.inbox5.com>
parents: 10549
diff changeset
75 ## @seealso{cellfun, arrayfun, spfun}
6863
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
76 ## @end deftypefn
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
77
30893
e1788b1a315f maint: Use "fcn" as preferred abbreviation for "function" in m-files.
Rik <rik@octave.org>
parents: 30875
diff changeset
78 function varargout = structfun (fcn, S, varargin)
10134
be13fa20656a error on invalid opts in structfun
Jaroslav Hajek <highegg@gmail.com>
parents: 10132
diff changeset
79
6863
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
80 if (nargin < 2)
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
81 print_usage ();
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
82 endif
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
83
10134
be13fa20656a error on invalid opts in structfun
Jaroslav Hajek <highegg@gmail.com>
parents: 10132
diff changeset
84 nargs = length (varargin);
be13fa20656a error on invalid opts in structfun
Jaroslav Hajek <highegg@gmail.com>
parents: 10132
diff changeset
85
be13fa20656a error on invalid opts in structfun
Jaroslav Hajek <highegg@gmail.com>
parents: 10132
diff changeset
86 recognized_opts = {"UniformOutput", "ErrorHandler"};
be13fa20656a error on invalid opts in structfun
Jaroslav Hajek <highegg@gmail.com>
parents: 10132
diff changeset
87 uo_str = recognized_opts{1};
be13fa20656a error on invalid opts in structfun
Jaroslav Hajek <highegg@gmail.com>
parents: 10132
diff changeset
88
10132
aa0f575cf39b improve structfun's Matlab compatibility
Jaroslav Hajek <highegg@gmail.com>
parents: 10122
diff changeset
89 uniform_output = true;
aa0f575cf39b improve structfun's Matlab compatibility
Jaroslav Hajek <highegg@gmail.com>
parents: 10122
diff changeset
90
10134
be13fa20656a error on invalid opts in structfun
Jaroslav Hajek <highegg@gmail.com>
parents: 10132
diff changeset
91 while (nargs >= 2)
be13fa20656a error on invalid opts in structfun
Jaroslav Hajek <highegg@gmail.com>
parents: 10132
diff changeset
92 opt_match = strcmpi (varargin{nargs-1}, recognized_opts);
be13fa20656a error on invalid opts in structfun
Jaroslav Hajek <highegg@gmail.com>
parents: 10132
diff changeset
93 if (opt_match(1))
be13fa20656a error on invalid opts in structfun
Jaroslav Hajek <highegg@gmail.com>
parents: 10132
diff changeset
94 uniform_output = varargin{nargs};
be13fa20656a error on invalid opts in structfun
Jaroslav Hajek <highegg@gmail.com>
parents: 10132
diff changeset
95 endif
be13fa20656a error on invalid opts in structfun
Jaroslav Hajek <highegg@gmail.com>
parents: 10132
diff changeset
96 if (any (opt_match))
be13fa20656a error on invalid opts in structfun
Jaroslav Hajek <highegg@gmail.com>
parents: 10132
diff changeset
97 nargs -= 2;
be13fa20656a error on invalid opts in structfun
Jaroslav Hajek <highegg@gmail.com>
parents: 10132
diff changeset
98 else
be13fa20656a error on invalid opts in structfun
Jaroslav Hajek <highegg@gmail.com>
parents: 10132
diff changeset
99 break;
be13fa20656a error on invalid opts in structfun
Jaroslav Hajek <highegg@gmail.com>
parents: 10132
diff changeset
100 endif
be13fa20656a error on invalid opts in structfun
Jaroslav Hajek <highegg@gmail.com>
parents: 10132
diff changeset
101 endwhile
be13fa20656a error on invalid opts in structfun
Jaroslav Hajek <highegg@gmail.com>
parents: 10132
diff changeset
102
be13fa20656a error on invalid opts in structfun
Jaroslav Hajek <highegg@gmail.com>
parents: 10132
diff changeset
103 if (nargs > 0)
be13fa20656a error on invalid opts in structfun
Jaroslav Hajek <highegg@gmail.com>
parents: 10132
diff changeset
104 error ("structfun: invalid options");
10132
aa0f575cf39b improve structfun's Matlab compatibility
Jaroslav Hajek <highegg@gmail.com>
parents: 10122
diff changeset
105 endif
aa0f575cf39b improve structfun's Matlab compatibility
Jaroslav Hajek <highegg@gmail.com>
parents: 10122
diff changeset
106
6863
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
107 varargout = cell (max ([nargout, 1]), 1);
30893
e1788b1a315f maint: Use "fcn" as preferred abbreviation for "function" in m-files.
Rik <rik@octave.org>
parents: 30875
diff changeset
108 [varargout{:}] = cellfun (fcn, struct2cell (S), varargin{:});
6863
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
109
10132
aa0f575cf39b improve structfun's Matlab compatibility
Jaroslav Hajek <highegg@gmail.com>
parents: 10122
diff changeset
110 if (! uniform_output)
19833
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19697
diff changeset
111 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
112 uo_str, false);
6863
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
113 endif
21758
ffad2baa90f7 maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents: 20852
diff changeset
114
6863
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
115 endfunction
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
116
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
117
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
118 %!test
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
119 %! s.name1 = "John Smith";
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
120 %! s.name2 = "Jill Jones";
6863
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
121 %! l.name1 = "Smith";
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
122 %! l.name2 = "Jones";
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
123 %! o = structfun (@(x) regexp (x, '(\w+)$', "matches"){1}, s,
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10134
diff changeset
124 %! "UniformOutput", false);
6863
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
125 %! assert (o, l);
10132
aa0f575cf39b improve structfun's Matlab compatibility
Jaroslav Hajek <highegg@gmail.com>
parents: 10122
diff changeset
126
13305
63463570d9fe Add %!endfunction block keyword to test.m
Rik <octave@nomad.inbox5.com>
parents: 12931
diff changeset
127 %!function [a, b] = __twoouts (x)
22627
7b190a2f11cb maint: Use 2-space indent in definition of BIST %!functions.
Rik <rik@octave.org>
parents: 22323
diff changeset
128 %! a = x + x;
7b190a2f11cb maint: Use 2-space indent in definition of BIST %!functions.
Rik <rik@octave.org>
parents: 22323
diff changeset
129 %! b = x * x;
13305
63463570d9fe Add %!endfunction block keyword to test.m
Rik <octave@nomad.inbox5.com>
parents: 12931
diff changeset
130 %!endfunction
10132
aa0f575cf39b improve structfun's Matlab compatibility
Jaroslav Hajek <highegg@gmail.com>
parents: 10122
diff changeset
131
aa0f575cf39b improve structfun's Matlab compatibility
Jaroslav Hajek <highegg@gmail.com>
parents: 10122
diff changeset
132 %!test
aa0f575cf39b improve structfun's Matlab compatibility
Jaroslav Hajek <highegg@gmail.com>
parents: 10122
diff changeset
133 %! 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
134 %! c(1:2, 1, 1) = [2; 8];
aa0f575cf39b improve structfun's Matlab compatibility
Jaroslav Hajek <highegg@gmail.com>
parents: 10122
diff changeset
135 %! c(1:2, 1, 2) = [4; 10];
aa0f575cf39b improve structfun's Matlab compatibility
Jaroslav Hajek <highegg@gmail.com>
parents: 10122
diff changeset
136 %! c(1:2, 1, 3) = [6; 12];
aa0f575cf39b improve structfun's Matlab compatibility
Jaroslav Hajek <highegg@gmail.com>
parents: 10122
diff changeset
137 %! d(1:2, 1, 1) = [1; 16];
aa0f575cf39b improve structfun's Matlab compatibility
Jaroslav Hajek <highegg@gmail.com>
parents: 10122
diff changeset
138 %! d(1:2, 1, 2) = [4; 25];
aa0f575cf39b improve structfun's Matlab compatibility
Jaroslav Hajek <highegg@gmail.com>
parents: 10122
diff changeset
139 %! 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
140 %! [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
141 %! assert (aa, c);
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14327
diff changeset
142 %! assert (bb, d);
10132
aa0f575cf39b improve structfun's Matlab compatibility
Jaroslav Hajek <highegg@gmail.com>
parents: 10122
diff changeset
143
aa0f575cf39b improve structfun's Matlab compatibility
Jaroslav Hajek <highegg@gmail.com>
parents: 10122
diff changeset
144 %!test
aa0f575cf39b improve structfun's Matlab compatibility
Jaroslav Hajek <highegg@gmail.com>
parents: 10122
diff changeset
145 %! 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
146 %! 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
147 %! 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
148 %! [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
149 %! assert (aa, c);
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14327
diff changeset
150 %! assert (bb, d);