Home > atmlab > gformat > gf_set_grid.m

gf_set_grid

PURPOSE ^

GF_SET_GRID Sets gformat grid data

SYNOPSIS ^

function G = gf_set_grid( G, dim, grid, name, unit )

DESCRIPTION ^

 GF_SET_GRID   Sets gformat grid data

    The fields GRIDx, GRIDx_NAME and GRIDx_UNIT can be set with the function,
    where x is *dim*.

 FORMAT   G = gf_set_grid( G, dim, grid [, name, unit ] )

 OUT   G     Modified gformat structure (array).
 IN    G     Original gformat structure (array).
       dim   Dimension.
       grid  Grid to be copied.
 OPT   name  Grid name.
       unit  Grid unit (a string).

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

gf_set_grid.m

SOURCE CODE ^

0001 % GF_SET_GRID   Sets gformat grid data
0002 %
0003 %    The fields GRIDx, GRIDx_NAME and GRIDx_UNIT can be set with the function,
0004 %    where x is *dim*.
0005 %
0006 % FORMAT   G = gf_set_grid( G, dim, grid [, name, unit ] )
0007 %
0008 % OUT   G     Modified gformat structure (array).
0009 % IN    G     Original gformat structure (array).
0010 %       dim   Dimension.
0011 %       grid  Grid to be copied.
0012 % OPT   name  Grid name.
0013 %       unit  Grid unit (a string).
0014 
0015 % 2010-01-06   Created by Patrick Eriksson.
0016 
0017 function G = gf_set_grid( G, dim, grid, name, unit )
0018 
0019 if atmlab('STRICT_ASSERT')
0020   rqre_nargin( 3, nargin );
0021   rqre_datatype( G, @isstruct );
0022   rqre_alltypes( dim, {@istensor0,@iswhole} );
0023   rqre_in_range( dim, 1 );
0024   rqre_datatype( grid, {@isempty,@istensor1} );
0025   if nargin>=4
0026     rqre_datatype( name, {@isempty,@ischar} );
0027     if nargin>=5
0028       rqre_datatype( unit, {@isempty,@ischar} );
0029     end
0030   end
0031 end
0032 
0033 
0034 bname = sprintf( 'GRID%d', dim );
0035 
0036 
0037 for i = 1 : length(G)
0038     
0039   G(i).(bname) = grid;
0040     
0041   if nargin >= 4
0042     G(i).([bname,'_NAME']) = name;
0043     if nargin >= 5
0044       G(i).([bname,'_UNIT']) = unit;
0045     end
0046   end
0047 end
0048 
0049

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