Home > atmlab > arts > scenegen > asg_copy_case.m

asg_copy_case

PURPOSE ^

ASG_COPY_CASE Copying of an ASG case

SYNOPSIS ^

function G = asg_copy_case( D, G, ncopies, icopy )

DESCRIPTION ^

 ASG_COPY_CASE   Copying of an ASG case

    Creates *ncopes* copes of the case specified by *icopy*. The copies are
    appended to the DATA field. The function assumes that cases are numbered
    followoing their index. The function makes further sure that *DIMS*
    includes the case dimension (4).

 FORMAT   G = asg_copy_case( D, G, ncopies [, icopy ] )
        
 OUT   G         Extended ASG data.
 IN    D         Gformat definition structure.
       G         ASG data.
       ncopies   Number of ciopies to create
 OPT   icopy     Index of case to copy. If set to empty, last case
                 will be copied. Default is [].

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

asg_copy_case.m

SOURCE CODE ^

0001 % ASG_COPY_CASE   Copying of an ASG case
0002 %
0003 %    Creates *ncopes* copes of the case specified by *icopy*. The copies are
0004 %    appended to the DATA field. The function assumes that cases are numbered
0005 %    followoing their index. The function makes further sure that *DIMS*
0006 %    includes the case dimension (4).
0007 %
0008 % FORMAT   G = asg_copy_case( D, G, ncopies [, icopy ] )
0009 %
0010 % OUT   G         Extended ASG data.
0011 % IN    D         Gformat definition structure.
0012 %       G         ASG data.
0013 %       ncopies   Number of ciopies to create
0014 % OPT   icopy     Index of case to copy. If set to empty, last case
0015 %                 will be copied. Default is [].
0016 
0017 % 2007-10-22   Created by Patrick Eriksson
0018 
0019 function G = asg_copy_case( D, G, ncopies, icopy )
0020 %
0021 icopy = optargs( varargin, { [] } );
0022 
0023   
0024 for ig = 1 : length(G)
0025   
0026   %- Reallocate DATA field
0027   %
0028   data          = G(ig).DATA;
0029   [n1,n2,n3,n4] = size( data );
0030   G(ig).DATA    = zeros( n1, n2, n3, n4+ncopies );
0031   %
0032   G(ig).DATA(:,:,:,1:n4) = data;
0033 
0034   %- Add new cases
0035   %
0036   if isempty( icopy )
0037     ic = n4;
0038   else
0039     ic = icopy;
0040   end
0041   %
0042   G(ig).DATA(:,:,:,n4+1:n4+ncopies) = ...
0043                                   repmat( data(:,:,:,ic), [ 1 1 1 ncopies ] );
0044   
0045   %- New case grid
0046   %
0047   G(ig).GRID4 = 1 : (n4+ncopies);  
0048   
0049   %- Ensure that "case dimension" is activated
0050   %
0051   if ~any( G(ig).DIMS == 4 )
0052     G(ig).DIMS(end+1) = 4;
0053   end
0054 end

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