comparison m-toolbox/classes/@param/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 param objects.
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %
4 % DESCRIPTION: COPY makes a deep copy of the input param objects.
5 %
6 % CALL: b = copy(a, flag)
7 %
8 % INPUTS: a - input param object
9 % flag - true: make a deep copy, false: return copies of handles
10 %
11 % OUTPUTS: b - copy of inputs
12 %
13 % VERSION: $Id: copy.m,v 1.18 2011/05/23 20:41:12 mauro Exp $
14 %
15 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
16
17 function varargout = copy(old, deepcopy)
18
19 if deepcopy
20 % Loop over input param objects
21 new = param.newarray(size(old));
22
23 for kk = 1:numel(old)
24 if isa(old(kk).val, 'ltpda_obj')
25 new(kk).val = copy(old(kk).val, true);
26 else
27 new(kk).val = old(kk).val;
28 end
29 new(kk).key = old(kk).key;
30 new(kk).desc = old(kk).desc;
31 end
32 else
33 new = old;
34 end
35
36 varargout{1} = new;
37 end
38