comparison m-toolbox/classes/@smodel/copy.m @ 0:f0afece42f48

Import.
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 23 Nov 2011 19:22:13 +0100
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:f0afece42f48
1 % COPY makes a (deep) copy of the input smodel objects.
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %
4 % DESCRIPTION: COPY makes a deep copy of the input smodel objects.
5 %
6 % CALL: b = copy(a, flag)
7 %
8 % INPUTS: a - input smodel object
9 % flag - 1: make a deep copy, 0: return copies of handles
10 %
11 % OUTPUTS: b - copy of inputs
12 %
13 % This is a transparent function and adds no history.
14 %
15 % VERSION: $Id: copy.m,v 1.7 2011/02/11 19:59:02 luigi Exp $
16 %
17 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
18
19 function varargout = copy(old, deepcopy)
20
21 if deepcopy
22 % Loop over input smodel objects
23 new = smodel.newarray(size(old));
24 obj = copy@ltpda_uoh(new, old, 1);
25
26 for kk=1:numel(old)
27 obj(kk).expr = old(kk).expr;
28 obj(kk).params = old(kk).params;
29 obj(kk).values = old(kk).values;
30 obj(kk).xvar = old(kk).xvar;
31 obj(kk).xvals = old(kk).xvals;
32 obj(kk).trans = old(kk).trans;
33 obj(kk).aliasNames = old(kk).aliasNames;
34 obj(kk).aliasValues = old(kk).aliasValues;
35 obj(kk).xunits = copy(old(kk).xunits,1);
36 obj(kk).yunits = copy(old(kk).yunits,1);
37 end
38 else
39 obj = old;
40 end
41
42 varargout{1} = obj;
43 end
44