comparison scripts/miscellaneous/getfield.m @ 6547:4fb053f24fd6

[project @ 2007-04-19 21:47:40 by jwe]
author jwe
date Thu, 19 Apr 2007 21:47:41 +0000
parents 18344a472daf
children 26f3d9bf9562
comparison
equal deleted inserted replaced
6546:44a4f68fbd76 6547:4fb053f24fd6
16 ## along with Octave; see the file COPYING. If not, write to the Free 16 ## along with Octave; see the file COPYING. If not, write to the Free
17 ## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 17 ## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 ## 02110-1301, USA. 18 ## 02110-1301, USA.
19 19
20 ## -*- texinfo -*- 20 ## -*- texinfo -*-
21 ## @deftypefn {Built-in Function} {} [@var{v1},...] = 21 ## @deftypefn {Built-in Function} {[@var{v1}, @dots{}] =} getfield (@var{s}, @var{key}, @dots{}) extract fields from a structure.
22 ## @code{getfield (@var{s}, 'k1',...)} extract fields from a structure.
23 ## For example 22 ## For example
24 ## 23 ##
25 ## @example 24 ## @example
26 ## @group 25 ## @group
27 ## ss(1,2).fd(3).b=5; 26 ## ss(1,2).fd(3).b=5;
28 ## getfield(ss,@{1,2@},'fd',@{3@},'b') 27 ## getfield (ss, @{1,2@}, "fd", @{3@}, "b")
29 ## @result{} ans = 5 28 ## @result{} ans = 5
30 ## @end group 29 ## @end group
31 ## @end example 30 ## @end example
32 ## 31 ##
33 ## Note that this function could be written as 32 ## Note that the function call in the previous example is equivalent to
33 ## the expression
34 ## 34 ##
35 ## @example 35 ## @example
36 ## i1= @{1,2@}; i2= 'fd'; i3= @{3@}; i4= 'b'; 36 ## i1= @{1,2@}; i2= "fd"; i3= @{3@}; i4= "b";
37 ## ss( i1@{:@} ).( i2 )( i3@{:@} ).( i4 ) 37 ## ss(i1@{:@}).(i2)(i3@{:@}).(i4)
38 ## @end example 38 ## @end example
39 ## @seealso{setfield, rmfield, isfield, isstruct, fieldnames, struct} 39 ## @seealso{setfield, rmfield, isfield, isstruct, fieldnames, struct}
40 ## @end deftypefn 40 ## @end deftypefn
41 41
42 ## Author: Etienne Grossmann <etienne@cs.uky.edu> 42 ## Author: Etienne Grossmann <etienne@cs.uky.edu>