Home > atmlab > gformat > gf_set.m

gf_set

PURPOSE ^

GF_SET Direct setting of gformat data

SYNOPSIS ^

function G = gf_set(G,data,grids,grid_names,grid_units,varargin)

DESCRIPTION ^

 GF_SET   Direct setting of gformat data

    To set a new G to a scalar and set some of the gformat fields:
      G = gf_set( [], 1e3, [], [], [], 'SOURCE', 'Set manually', 'NAME', 'X' );

 FORMAT   G = gf_set(G,data,grids,grid_names,grid_units,field1,string1,...)
        
 OUT   G              Modified gformat structure.
 IN    G              Original gformat structure.
 IN    data           Data to be inserted.
       grids          Grids corresponding to data, given as an array of 
                      vectors.
 OPT   grid_names     Empty (default) or an array of strings with name of 
                      each grid.
       grid_units     Empty (default) or an array of strings with unit of 
                      each grid.
       field/string   Combinations of field names and strings.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

gf_set.m

SOURCE CODE ^

0001 % GF_SET   Direct setting of gformat data
0002 %
0003 %    To set a new G to a scalar and set some of the gformat fields:
0004 %      G = gf_set( [], 1e3, [], [], [], 'SOURCE', 'Set manually', 'NAME', 'X' );
0005 %
0006 % FORMAT   G = gf_set(G,data,grids,grid_names,grid_units,field1,string1,...)
0007 %
0008 % OUT   G              Modified gformat structure.
0009 % IN    G              Original gformat structure.
0010 % IN    data           Data to be inserted.
0011 %       grids          Grids corresponding to data, given as an array of
0012 %                      vectors.
0013 % OPT   grid_names     Empty (default) or an array of strings with name of
0014 %                      each grid.
0015 %       grid_units     Empty (default) or an array of strings with unit of
0016 %                      each grid.
0017 %       field/string   Combinations of field names and strings.
0018 
0019 % 2007-10-17   Created by Patrick Eriksson.
0020 
0021 function G = gf_set(G,data,grids,grid_names,grid_units,varargin)
0022 %
0023 if nargin < 4, grid_names = []; end
0024 if nargin < 5, grid_units = []; end
0025 
0026 
0027 %- Check input                                                             %&%
0028 %                                                                          %&%
0029 rqre_nargin( 1, nargin );                                                  %&%
0030 rqre_datatype( data, @isnumeric );                                         %&%
0031 rqre_datatype( grids, {@isempty,@iscell} );                                %&%
0032 rqre_datatype( grid_names, {@isempty,@iscellstr} );                        %&%
0033 rqre_datatype( grid_units, {@isempty,@iscellstr} );                        %&%
0034 if isodd( length( varargin ) )                                             %&%
0035   error( ['The number of input arguments after *grid_units* ',...          %&%
0036                                     'must be an even number.'] );          %&%
0037 end                                                                        %&%
0038 
0039 G = gf_set_data( G, data,grids,grid_names );
0040 
0041 if ~isempty( varargin )
0042   G = gf_set_fields( G, varargin{:} );
0043 end

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