Mercurial > hg > ltpda
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/m-toolbox/classes/@param/copy.m Wed Nov 23 19:22:13 2011 +0100 @@ -0,0 +1,38 @@ +% COPY makes a (deep) copy of the input param objects. +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% DESCRIPTION: COPY makes a deep copy of the input param objects. +% +% CALL: b = copy(a, flag) +% +% INPUTS: a - input param object +% flag - true: make a deep copy, false: return copies of handles +% +% OUTPUTS: b - copy of inputs +% +% VERSION: $Id: copy.m,v 1.18 2011/05/23 20:41:12 mauro Exp $ +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +function varargout = copy(old, deepcopy) + + if deepcopy + % Loop over input param objects + new = param.newarray(size(old)); + + for kk = 1:numel(old) + if isa(old(kk).val, 'ltpda_obj') + new(kk).val = copy(old(kk).val, true); + else + new(kk).val = old(kk).val; + end + new(kk).key = old(kk).key; + new(kk).desc = old(kk).desc; + end + else + new = old; + end + + varargout{1} = new; +end +