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) M-FILE INFO: Get information about this methods by calling >> ao.getInfo('extractmdl') Get information about a specified set-plist by calling: >> ao.getInfo('extractmdl', 'None') VERSION: $Id: extractmdl.m,v 1.7 2008/09/05 11:05:29 ingo Exp $ HISTORY: 31-03-07 M Hewitson Creation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0001 % EXTRACTMDL extracts an mdl file from an analysis object and saves it to disk. 0002 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0003 % 0004 % DESCRIPTION: EXTRACTMDL extracts an mdl file from an analysis object and saves 0005 % it to disk. 0006 % 0007 % CALL: extractmdl(a) 0008 % 0009 % M-FILE INFO: Get information about this methods by calling 0010 % >> ao.getInfo('extractmdl') 0011 % 0012 % Get information about a specified set-plist by calling: 0013 % >> ao.getInfo('extractmdl', 'None') 0014 % 0015 % VERSION: $Id: extractmdl.m,v 1.7 2008/09/05 11:05:29 ingo Exp $ 0016 % 0017 % HISTORY: 31-03-07 M Hewitson 0018 % Creation 0019 % 0020 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0021 0022 function varargout = extractmdl(varargin) 0023 0024 % Check if this is a call for parameters 0025 if utils.helper.isinfocall(varargin{:}) 0026 varargout{1} = getInfo(varargin{3}); 0027 return 0028 end 0029 0030 import utils.const.* 0031 utils.helper.msg(msg.MNAME, 'running %s/%s', mfilename('class'), mfilename); 0032 0033 % Collect input variable names 0034 in_names = cell(size(varargin)); 0035 for ii = 1:nargin,in_names{ii} = inputname(ii);end 0036 0037 % Collect all AOs 0038 [as, ao_invars] = utils.helper.collect_objects(varargin(:), 'ao', in_names); 0039 0040 % Loop over AOs 0041 for jj=1:numel(as) 0042 if isempty(as(j).mdlfile) 0043 warning('!!! No model found in %s. Skipping.', ao_invars{j}); 0044 end 0045 if isempty(as(j).mdlfilename) 0046 warning('!!! No model filename found in %s. Skipping.', ao_invars{j}); 0047 end 0048 % split mdl contents by \n in to cell array 0049 mdlfile = regexp(as(j).mdlfile, '\\n', 'split'); 0050 % reformat into a big string 0051 txt = sprintf([repmat('%s\t',1,size(mdlfile,1)),'\n'],mdlfile{:}); 0052 txt = strrep(txt, '`', ''''); 0053 % write string to disk 0054 fd = fopen(as(j).mdlfilename, 'w+'); 0055 fwrite(fd, txt); 0056 fclose(fd); 0057 utils.helper.msg(msg.PROC1, 'saved model to %s', as(j).mdlfilename); 0058 end 0059 0060 % Set output 0061 if nargout > 0 0062 varargout{1} = as; 0063 end 0064 end 0065 0066 %-------------------------------------------------------------------------- 0067 % Get Info Object 0068 %-------------------------------------------------------------------------- 0069 function ii = getInfo(varargin) 0070 if nargin == 1 && strcmpi(varargin{1}, 'None') 0071 sets = {}; 0072 pl = []; 0073 else 0074 sets = {'Default'}; 0075 pl = getDefaultPlist; 0076 end 0077 % Build info object 0078 ii = minfo(mfilename, 'ao', '', utils.const.categories.output, '$Id: extractmdl.m,v 1.7 2008/09/05 11:05:29 ingo Exp $', sets, pl); 0079 end 0080 0081 %-------------------------------------------------------------------------- 0082 % Get Default Plist 0083 %-------------------------------------------------------------------------- 0084 function pl_default = getDefaultPlist() 0085 pl_default = plist(); 0086 end 0087 0088