FROMFCN Construct an ao from a function string %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FUNCTION: fromFcn DESCRIPTION: Construct an ao from a function string CALL: a = fromFcn(a, pl) PARAMETER: pl: Parameter list object HISTORY: 07-05-2007 Hewitson Creation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0001 % FROMFCN Construct an ao from a function string 0002 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0003 % 0004 % FUNCTION: fromFcn 0005 % 0006 % DESCRIPTION: Construct an ao from a function string 0007 % 0008 % CALL: a = fromFcn(a, pl) 0009 % 0010 % PARAMETER: 0011 % pl: Parameter list object 0012 % 0013 % HISTORY: 07-05-2007 Hewitson 0014 % Creation 0015 % 0016 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0017 function a = fromFcn(a, pli) 0018 0019 VERSION = '$Id: fromFcn.m,v 1.11 2008/09/04 13:37:14 ingo Exp $'; 0020 % get AO info 0021 ii = ao.getInfo('ao', 'From Function'); 0022 0023 % Set the method version string in the minfo object 0024 ii.setMversion([VERSION '-->' ii.mversion]); 0025 0026 % Add default values 0027 pl = combine(pli, ii.plists); 0028 0029 fcn = find(pl, 'fcn'); 0030 randn_state = find(pl, 'rand_state'); 0031 0032 % If the randn state is in the parameter list then set the randn function to 0033 % this sate 0034 if ~isempty(randn_state) 0035 randn('state',randn_state); 0036 else % Store the state of the random function in the parameter list 0037 randn_state = randn('state'); 0038 pl.append('rand_state', randn_state); 0039 end 0040 0041 % find all other parameters and try to evaluate them 0042 for jj=1:nparams(pl) 0043 p = pl.params(jj); 0044 if ~strcmpi(fcn, p.val) 0045 % try upper case replacement 0046 fcn = strrep(fcn, p.key, mat2str(p.val)); 0047 % try lower case replacement 0048 fcn = strrep(fcn, lower(p.key), mat2str(p.val)); 0049 end 0050 end 0051 0052 % Set data of analysis object 0053 a.data = cdata(eval(fcn)); 0054 % Add history 0055 a.addHistory(ii, pl, [], []); 0056 0057 end 0058