comparison m-toolbox/classes/@ltpda_uo/fromModel.m @ 0:f0afece42f48

Import.
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 23 Nov 2011 19:22:13 +0100
parents
children bc767aaa99a8
comparison
equal deleted inserted replaced
-1:000000000000 0:f0afece42f48
1 % FROMMODEL Construct an a built in model
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %
4 % FUNCTION: fromModel
5 %
6 % DESCRIPTION: Construct an ltpda uder objects with history from a
7 % built-in model
8 %
9 % CALL: a = fromModel(a, pl)
10 %
11 % PARAMETER: pl: Parameter list object
12 %
13 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
14
15 function [obj, ii, fcnname] = fromModel(obj, pl)
16
17 % Get the name of the model the user wants
18 model = find(pl, 'built-in');
19
20 % Get a list of user model directories
21 paths = utils.models.getBuiltinModelSearchPaths();
22
23 for jj = 1:numel(paths)
24 utils.helper.msg(utils.const.msg.PROC1, 'looking for models in %s', paths{jj});
25 end
26
27 % Give an error if the model name is a number
28 if isnumeric(model)
29 error(['### This syntax is no more supported. Please choose a model from the list you can obtain with: ' ...
30 '''%s.getBuiltInModels'''], class(obj));
31 end
32
33 % Give an error if the model name is empty
34 if isempty(model)
35 error(['### No model specified. Please choose one from the list you can obtain with: ' ...
36 '''%s.getBuiltInModels'''], class(obj));
37 end
38
39 % Find the matching model
40 try
41 fcnname = sprintf('%s_model_%s', class(obj), model);
42 ii = obj.getInfo(class(obj), 'From Built-in Model');
43 [obj, pl] = feval(fcnname, pl, ii);
44 catch ME
45 if strcmp(ME.identifier, 'MATLAB:UndefinedFunction') && length(ME.stack) == 3
46 % If the model is missing, tell the user
47 error(['### Model named ''%s'' not found. Please choose one from the list you can obtain with: ' ...
48 '''%s.getBuiltInModels'''], model, class(obj));
49 else
50 % If the error is different, just notify the user
51 rethrow(ME);
52 end
53 end
54
55 end
56