Home > rest_20090422 > rest_spm5_files > @create_file_array > cat.m

cat

PURPOSE ^

Concatenate file_array objects. The result is a non-simple object

SYNOPSIS ^

function o = cat(dr,varargin)

DESCRIPTION ^

 Concatenate file_array objects.  The result is a non-simple object
 that can no longer be reshaped.
 _______________________________________________________________________
 Copyright (C) 2005 Wellcome Department of Imaging Neuroscience

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

cat.m

SOURCE CODE ^

0001 function o = cat(dr,varargin)
0002 % Concatenate file_array objects.  The result is a non-simple object
0003 % that can no longer be reshaped.
0004 % _______________________________________________________________________
0005 % Copyright (C) 2005 Wellcome Department of Imaging Neuroscience
0006 
0007 %
0008 % $Id: cat.m 253 2005-10-13 15:31:34Z guillaume $
0009 
0010 
0011 if dr>32 || dr<0, error('Unknown command option.'); end;
0012 dr   = max(round(dr),1);
0013 d    = ones(nargin-1,16);
0014 tmp  = {};
0015 dpos = 0;
0016 for i=1:nargin-1,
0017     vi = varargin{i};
0018     if strcmp(class(vi),'create_file_array')
0019         sz                = size(vi);
0020         d(i,1:length(sz)) = sz;
0021         svi               = struct(vi);
0022         svi               = svi(:);
0023         for j=1:length(svi(:)),
0024             if length(svi(j).pos)<dr
0025                 svi(j).pos((length(svi(j).pos)+1):dr) = 1;
0026             end
0027             svi(j).pos(dr)= svi(j).pos(dr) + dpos;
0028         end;
0029         dpos              = dpos + d(i,dr);
0030         tmp{i}            = svi;
0031     else
0032         error(['Conversion to create_file_array from ' class(vi) ' is not possible.']);
0033     end;
0034 end;
0035 if any(diff(d(:,[1:(dr-1) (dr+1):end]),1,1))
0036     error('All matrices on a row in the bracketed expression must have the same number of rows.');
0037 else
0038     o = vertcat(tmp{:});
0039     o = class(o,'create_file_array');
0040 end;

Generated on Wed 29-Apr-2009 01:06:38 by m2html © 2005