EXTRACTM extracts an m-file from an analysis object and saves it to disk. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DESCRIPTION: EXTRACTM extracts an m-file from an analysis object and saves it to disk. CALL: extractm(a) VERSION: $Id: extractm.m,v 1.2 2008/03/01 16:09:02 hewitson Exp $ HISTORY: 23-02-08 M Hewitson Creation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0001 function a = extractm(varargin) 0002 % EXTRACTM extracts an m-file from an analysis object and saves it to 0003 % disk. 0004 % 0005 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0006 % 0007 % DESCRIPTION: EXTRACTM extracts an m-file from an analysis object and saves it to 0008 % disk. 0009 % 0010 % CALL: extractm(a) 0011 % 0012 % VERSION: $Id: extractm.m,v 1.2 2008/03/01 16:09:02 hewitson Exp $ 0013 % 0014 % HISTORY: 23-02-08 M Hewitson 0015 % Creation 0016 % 0017 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0018 0019 VERSION = '$Id: extractm.m,v 1.2 2008/03/01 16:09:02 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 mfile = regexp(a.mfile, '\\n', 'split'); 0043 % reformat into a big string 0044 txt = sprintf([repmat('%s\t',1,size(mfile,1)),'\n'],mfile{:}); 0045 txt = strrep(txt, '`', ''''); 0046 % write string to disk 0047 fd = fopen(a.mfilename, 'w+'); 0048 fwrite(fd, txt); 0049 fclose(fd); 0050 0051 disp(sprintf('*** saved m-file to %s', a.mfilename)); 0052 0053 % END