NAMEFROMVARIED - makes a filename based on the parameters in data.varied. Usage: new_result_file = dsNameFromVaried(data, file_type, old_result_file) Inputs: - data: DynaSim data structure (also accepted: data file name) - file_type: file prefix for type of file - result_file: previous result_file, only uses this for the path. Outputs: - new_result_file: where to save result, based on file_type and data.varied
0001 function new_result_file = dsNameFromVaried(data, file_type, old_result_file) 0002 %NAMEFROMVARIED - makes a filename based on the parameters in data.varied. 0003 % 0004 % Usage: 0005 % new_result_file = dsNameFromVaried(data, file_type, old_result_file) 0006 % 0007 % Inputs: 0008 % - data: DynaSim data structure (also accepted: data file name) 0009 % - file_type: file prefix for type of file 0010 % - result_file: previous result_file, only uses this for the path. 0011 % 0012 % Outputs: 0013 % - new_result_file: where to save result, based on file_type and data.varied 0014 0015 pathstr = fileparts2(old_result_file); 0016 0017 fileName = file_type; 0018 0019 %check for simID# from batch sims 0020 token = regexp(old_result_file, '(sim\d+)', 'tokens'); 0021 if ~isempty(token) 0022 fileName = [fileName '_' token{1}{1}]; 0023 end 0024 0025 for param = data.varied(:)' 0026 fileName = [fileName '__' param{1} '_' sprintf('%g',data.(param{1}))]; 0027 end 0028 0029 new_result_file = fullfile(pathstr, fileName); 0030 0031 end