STRING writes a command string that can be used to recreate the input param object. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DESCRIPTION: STRING writes a command string that can be used to recreate the input param object. CALL: cmd = string(param_obj) INPUT: param_obj - parameter object OUTPUT: cmd - command string to create the input object VERSION: $Id: string.m,v 1.1 2008/02/15 17:38:59 ingo Exp $ HISTORY: 15-02-2008 Diepholz Creation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0001 function cmd = string(objs, varargin) 0002 % STRING writes a command string that can be used to recreate the input param object. 0003 % 0004 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0005 % 0006 % DESCRIPTION: STRING writes a command string that can be used to recreate the 0007 % input param object. 0008 % 0009 % CALL: cmd = string(param_obj) 0010 % 0011 % INPUT: param_obj - parameter object 0012 % 0013 % OUTPUT: cmd - command string to create the input object 0014 % 0015 % VERSION: $Id: string.m,v 1.1 2008/02/15 17:38:59 ingo Exp $ 0016 % 0017 % HISTORY: 15-02-2008 Diepholz 0018 % Creation 0019 % 0020 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0021 0022 VERSION = '$Id: string.m,v 1.1 2008/02/15 17:38:59 ingo Exp $'; 0023 CATEGORY = 'Output'; 0024 0025 % Check if this is a call for parameters 0026 if nargin == 2 0027 if isa(objs, 'param') && ischar(varargin{1}) 0028 in = char(varargin{1}); 0029 if strcmp(in, 'Params') 0030 cmd = plist; 0031 return 0032 elseif strcmp(in, 'Version') 0033 cmd = VERSION; 0034 return 0035 elseif strcmp(in, 'Category') 0036 cmd = CATEGORY; 0037 return 0038 end 0039 end 0040 end 0041 0042 %%% Wrap the command only in bracket if the there are more than one object 0043 if length(objs) > 1 0044 cmd = '['; 0045 else 0046 cmd = ''; 0047 end 0048 0049 for j=1:length(objs) 0050 obj = objs(j); 0051 key = obj.key; 0052 val = obj.val; 0053 0054 if ischar(val) 0055 val_str = ['''' val '''']; 0056 elseif isnumeric(val) 0057 val_str = ltpda_mat2str(val); 0058 elseif isobject(val) 0059 val_str = string(val); 0060 else 0061 error('### Unknown object [%s]', class(val)); 0062 end 0063 0064 cmd = [cmd 'param(''' key ''', ' val_str ') ']; 0065 end 0066 0067 if length(objs) > 1 0068 cmd = [cmd ']']; 0069 end 0070 0071 % END