EXTRACTMDL extracts an mdl file from an analysis object and saves it to disk. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DESCRIPTION: EXTRACTMDL extracts an mdl file from an analysis object and saves it to disk. CALL: extractmdl(a) VERSION: $Id: extractmdl.html,v 1.4 2008/03/31 10:27:33 hewitson Exp $ HISTORY: 31-03-07 M Hewitson Creation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0001 function a = extractmdl(varargin) 0002 % EXTRACTMDL extracts an mdl file from an analysis object and saves it to 0003 % disk. 0004 % 0005 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0006 % 0007 % DESCRIPTION: EXTRACTMDL extracts an mdl file from an analysis object and saves it to 0008 % disk. 0009 % 0010 % CALL: extractmdl(a) 0011 % 0012 % VERSION: $Id: extractmdl.html,v 1.4 2008/03/31 10:27:33 hewitson Exp $ 0013 % 0014 % HISTORY: 31-03-07 M Hewitson 0015 % Creation 0016 % 0017 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0018 0019 VERSION = '$Id: extractmdl.html,v 1.4 2008/03/31 10:27:33 hewitson Exp $'; 0020 CATEGORY = 'Output'; 0021 0022 % Check if this is a call for parameters 0023 if nargin == 2 0024 if isa(varargin{1}, 'ao') 0025 in = varargin{2}; 0026 if strcmp(in, 'Params') 0027 a = plist; 0028 return 0029 elseif strcmp(in, 'Version') 0030 a = VERSION; 0031 return 0032 elseif strcmp(in, 'Category') 0033 a = CATEGORY; 0034 return 0035 end 0036 end 0037 end 0038 0039 a = varargin{1}; 0040 0041 % split mdl contents by \n in to cell array 0042 mdlfile = regexp(a.mdlfile, '\\n', 'split'); 0043 % reformat into a big string 0044 txt = sprintf([repmat('%s\t',1,size(mdlfile,1)),'\n'],mdlfile{:}); 0045 txt = strrep(txt, '`', ''''); 0046 % write string to disk 0047 fd = fopen(a.mdlfilename, 'w+'); 0048 fwrite(fd, txt); 0049 fclose(fd); 0050 0051 disp(sprintf('*** saved model to %s', a.mdlfilename)); 0052 0053 % END