Home > atmlab > gformat > gf_set_fields.m

gf_set_fields

PURPOSE ^

GF_SET_FIELDS Setting of character fields

SYNOPSIS ^

function G = gf_set_fields(G,varargin)

DESCRIPTION ^

 GF_SET_FIELDS   Setting of character fields

   An example:
      G = gf_set( G, 'SOURCE', 'Set manually', 'NAME', 'X' );

 FORMAT   G = gf_set_fields(G [, field1, string1, ...] )
        
 OUT   G              Modified gformat structure.
 IN    G              Original gformat structure.
 OPT   field/string   Combinations of field names and strings.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

gf_set_fields.m

SOURCE CODE ^

0001 % GF_SET_FIELDS   Setting of character fields
0002 %
0003 %   An example:
0004 %      G = gf_set( G, 'SOURCE', 'Set manually', 'NAME', 'X' );
0005 %
0006 % FORMAT   G = gf_set_fields(G [, field1, string1, ...] )
0007 %
0008 % OUT   G              Modified gformat structure.
0009 % IN    G              Original gformat structure.
0010 % OPT   field/string   Combinations of field names and strings.
0011 
0012 % 2007-10-17   Created by Patrick Eriksson.
0013 
0014 function G = gf_set_fields(G,varargin)
0015 
0016 strict_assert = atmlab('STRICT_ASSERT');
0017 
0018 if strict_assert
0019   rqre_nargin( 1, nargin );
0020   if ~iseven( length( varargin ) )
0021     error( ['The number of input arguments must be an even number.'] );
0022   end
0023 end
0024 
0025 for i = 1 : 2: length(varargin)
0026   if strict_assert
0027     rqre_datatype( varargin{i}, {@ischar}, 'Field names' );
0028     rqre_datatype( varargin{i+1}, {@ischar,@isempty}, ... 
0029                                                'An optional field argument' );
0030   end
0031   G = setfield( G, varargin{i}, varargin{i+1} );
0032 end

Generated on Mon 15-Sep-2014 13:31:28 by m2html © 2005