view m-toolbox/classes/@ssm/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 source

% COPY Make copy of ssm objects depending of the second input
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% DESCRIPTION: COPY Make copy of ssm objects depending of the second input
%
% CALL:        objs = copy(objs, [1,0]);
%              objs = copy(objs); Second input is assumed to be 1
%
%  This is a transparent function and adds no history.
% 
% VERSION: $Id: copy.m,v 1.30 2010/08/18 19:40:52 adrien Exp $
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% HISTORY:     07-08-2008 Grynagier - made second input facultative
%              11-07-2008 Diepholz
%                 Creation

function varargout = copy(old, deepcopy)
  
  % begin function body
  
  if deepcopy
    new = ssm.newarray(size(old));
    new = copy@ltpda_uoh(new, old, 1);

    for kk=1:numel(old)
      new(kk).amats       = old(kk).amats;
      new(kk).bmats       = old(kk).bmats;
      new(kk).cmats       = old(kk).cmats;
      new(kk).dmats       = old(kk).dmats;
      new(kk).timestep    = old(kk).timestep;
      new(kk).inputs      = copy(old(kk).inputs, 1);
      new(kk).states      = copy(old(kk).states, 1);
      new(kk).outputs     = copy(old(kk).outputs, 1);
      new(kk).params      = copy(old(kk).params, 1);
      new(kk).numparams   = copy(old(kk).numparams, 1);
    end
  else
    new = old;
  end
  varargout{1} = new;
  
end