deepcopy

PURPOSE ^

DEEPCOPY - copies a model

SYNOPSIS ^

function md2=deepcopy(md)

DESCRIPTION ^

DEEPCOPY - copies a model

   This routine will copy md into md2. If md is being held in an out of core 
   repository, user will be prompted for a different repository name, and a 
   copy of the repository, with the new name, will be done.

   Usage:
      md2=deepcopy(md)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function md2=deepcopy(md)
0002 %DEEPCOPY - copies a model
0003 %
0004 %   This routine will copy md into md2. If md is being held in an out of core
0005 %   repository, user will be prompted for a different repository name, and a
0006 %   copy of the repository, with the new name, will be done.
0007 %
0008 %   Usage:
0009 %      md2=deepcopy(md)
0010 
0011 if isempty(md.repository),
0012     md2=md;
0013 else
0014     %New repository name?
0015     new_repository=input(['   input model is held in repository: ' md.repository '. you need a new name for the model copy: ']);
0016     md2=model(new_repository);
0017 
0018     structfields=fields(md);
0019     for i=1:length(structfields),
0020         field=structfields(i);field=field{1};
0021         if strcmpi(field,'repository'),
0022             %we don't want to clobber md2.repository!
0023             continue;
0024         end
0025         fieldval=getfield(md,field);
0026         if isfield(struct(md2),field),
0027             eval(['md2.' field '=fieldval;']);
0028         end
0029     end
0030 end

Generated on Sun 29-Mar-2009 20:22:55 by m2html © 2003