0001 function weights = prt_weights(d,m)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018 SANITYCHECK = true;
0019
0020
0021
0022 if SANITYCHECK == true
0023 if ~isempty(m)
0024 if isstruct(m)
0025 if isfield(m,'function')
0026 if ~ischar(m.function)
0027 error('prt_weights:functionNotString',...
0028 'Error: ''function'' should be a string!');
0029 end
0030 if ~exist(m.function,'file')
0031 error('prt_weights:functionFileNotFound',...
0032 'Error: %s function could not be found!',...
0033 m.function);
0034 end
0035 else
0036 error('prt_weights:functionNotField',...
0037 'Error: ''function'' should be a field of machine!');
0038 end
0039 if ~isfield(m,'args')
0040 m.args = [];
0041 end
0042 else
0043 error('prt_weights:machineNotStruct',...
0044 'Error: machine should be a structure!');
0045 end
0046 else
0047 error('prt_weights:machineEmpty',...
0048 'Error: ''machine'' cannot be empty!');
0049 end
0050 if ~isempty(d)
0051 if ~isstruct(d)
0052 error('prt_weights:dataNotStruct',...
0053 'Error: data should be a structure!');
0054 end
0055 else
0056 error('prt_weights:dataStructEmpty',...
0057 'Error: ''data'' struct cannot be empty!');
0058 end
0059 end
0060
0061
0062
0063 fnch = str2func(m.function);
0064 weights = fnch(d,m.args);
0065
0066
0067
0068 if SANITYCHECK == true
0069 if ~isvector(weights)
0070 error('prt_weights:weightsNotVector',...
0071 'Error: weights should be a vector!');
0072 end
0073 end