Home > marsbar > @marsy > join.m

join

PURPOSE ^

joins marsy objects into one object

SYNOPSIS ^

function o = join(varargin)

DESCRIPTION ^

 joins marsy objects into one object
 
 $Id$

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function o = join(varargin)
0002 % joins marsy objects into one object
0003 %
0004 % $Id$
0005 
0006 % assemble all input object into a cell array
0007 % (deals with arrays of objects)
0008 o_c_a = {};
0009 ctr = 0;
0010 n_n = [];
0011 for v = 1:nargin
0012   o_arr = varargin{v};
0013   for i = 1:prod(size(o_arr))
0014     ctr = ctr + 1;
0015     
0016     % Check number of time points
0017     n = n_time_points(o_arr(i));
0018     if isempty(n_n), n_n = n;
0019     else
0020       if n ~= n_n
0021     error(sprintf(...
0022         'Regions %d and %d have different numbers of time points',...
0023         ctr, ctr-1));
0024       end
0025     end
0026     
0027     o_c_a{ctr} = o_arr(i);
0028   end
0029 end
0030 
0031 o = o_c_a{1};
0032 want_sum_f = 1;
0033 sum_func = sumfunc(o);
0034 regions = {};
0035 Y = [];
0036 Yvar = [];
0037 for i = 1:ctr
0038   o_a = o_c_a{i};
0039   if want_sum_f
0040     % if summary function differs from other
0041     % objects, abort collecting summary data
0042     if ~strcmp(sum_func,sumfunc(o_a)) | ...
0043       ~can_summarize(o_a)
0044       want_sum_f = 0;
0045     else
0046       if ~is_summarized(o_a)
0047     o_a = resummarize(o_a);
0048       end
0049       [t1 t2] = summary_data(o_a);
0050       Y =    [Y t1];
0051       Yvar = [Yvar t2];
0052     end
0053   end
0054   regions = [regions region(o_a)];
0055 end
0056 
0057 st = y_struct(o);
0058 if want_sum_f
0059   st.Y = Y;
0060   st.Yvar = Yvar;
0061   st.sumfunc = sum_func;
0062 else
0063   st = mars_struct('strip', st, {'Y','Yvar','sumfunc'});
0064 end
0065 st.regions = regions;
0066 o = y_struct(o, st);

Generated on Wed 11-May-2022 16:26:09 by m2html © 2003-2019