0001 function varargout = single_operation (varargin)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039 ALGONAME = mfilename;
0040 VERSION = '$Id: single_operation.m,v 1.9 2007/07/11 16:01:24 ingo Exp $';
0041
0042
0043 if (nargin == 3)
0044
0045 data = varargin {1};
0046 op = varargin {2};
0047 pl = varargin {3};
0048 a = varargin {end};
0049 vals = data.vals;
0050 option_dim = '';
0051
0052
0053 if ~isa(data, 'cdata')
0054 error ('### cdata/single_operation: The first input must be a cdata.');
0055 end
0056 if ~ischar(op)
0057 error ('### cdata/single_operation: The second input must be a string.');
0058 end
0059 if ~isa(plist, 'plist')
0060 error ('### cdata/single_operation: The third input must be a plist.');
0061 end
0062
0063
0064 pl_default = plist([param('option', '')
0065 param('dim', '')
0066 param('W', [])
0067 param('xdata', 'vals')
0068 param('ydata', 'vals')]);
0069
0070
0071 if ~isempty(pl)
0072 pl = combine(pl);
0073 else
0074 pl = combine(pl_default);
0075 end
0076
0077 option = find(pl, 'option');
0078 dim = find(pl, 'dim');
0079 weight_vector = find(pl, 'W');
0080 do_xdata = find(pl, 'xdata');
0081 do_ydata = find(pl, 'ydata');
0082
0083
0084
0085 if ischar(option) && ~isempty(option)
0086 if ~strcmp(option(1), '''')
0087 option = ['''' option];
0088 end
0089 if ~strcmp(option(end), '''')
0090 option = [option ''''];
0091 end
0092 disp('sdf')
0093 end
0094
0095
0096 if isnumeric(option) || islogical(option)
0097 option = num2str(option);
0098 end
0099
0100
0101 do_xdata = 'vals';
0102 do_ydata = 'vals';
0103
0104
0105 if isnumeric(dim) || islogical (dim)
0106 dim = num2str(dim);
0107 end
0108
0109
0110
0111
0112 if ~isempty(option) && ~isempty(dim)
0113 warning ('### xydata/single_operation: The param list contain a ''option'' and a ''dim''. It is computed %s(ao,option).', op);
0114 end
0115
0116
0117 if (nargout >= 2)
0118
0119
0120
0121 vals_new = '[';
0122 for i = 1:nargout-1
0123 new_var_name = genvarname (sprintf('vals_new%d',i));
0124 eval ([new_var_name '= 0;']);
0125
0126 vals_new = strcat(vals_new, sprintf (' vals_new%d',i));
0127 end
0128 vals_new = strcat (vals_new, ' ]');
0129
0130
0131
0132 for i = 1:nargout-1
0133 new_var_name = genvarname (sprintf('data_out%d',i));
0134 eval ([new_var_name '= data;']);
0135 end
0136
0137
0138
0139 try
0140
0141
0142
0143 if ~isempty(option)
0144 cmd_line = sprintf('%s = %s(vals,%s);',vals_new, op, option);
0145 eval (cmd_line);
0146
0147
0148
0149 elseif ~isempty(dim) && ~isempty(weight_vector)
0150 cmd_line = sprintf('%s = %s(vals,weight_vector,%s);',vals_new, op, dim);
0151 eval (cmd_line);
0152
0153
0154
0155 elseif ~isempty(dim)
0156 cmd_line = sprintf('%s = %s(vals,%s);',vals_new, op, dim);
0157 eval (cmd_line);
0158
0159
0160
0161 elseif ~isempty(weight_vector)
0162 cmd_line = sprintf('%s = %s(vals,weight_vector);',vals_new, op);
0163 eval (cmd_line);
0164
0165
0166
0167 else
0168 cmd_line = sprintf('%s = %s(vals);',vals_new, op);
0169 eval (cmd_line);
0170 end
0171
0172 catch
0173 l_error = lasterror;
0174 disp(sprintf('\n\n%s', l_error.message));
0175 error('### cdata/single_operation: Can not command:\n### %s\n### Have a look to the param list', cmd_line);
0176 end
0177
0178
0179
0180
0181 for i = 1:nargout-1
0182
0183
0184 eval (sprintf('data_out%d.vals = vals_new%d;',i,i));
0185 eval (sprintf('data_out%d.name = ''%s(%s)'';',i,op,data.name));
0186
0187
0188 eval (sprintf('varargout{i+1} = data_out%d;',i))
0189
0190 end
0191
0192
0193 h = history(op, VERSION);
0194
0195 varargout{1} = h;
0196
0197 else
0198 error ('### cdata/single_operation: This function need at least two output variables.');
0199 end
0200
0201 else
0202 error ('### cdata/single_operation: This function need three input variables.')
0203 end