Mercurial > hg > ltpda
comparison m-toolbox/classes/+utils/@models/mainFnc.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 % MAINFNC is the main function call for all built-in models. | |
2 % | |
3 % CALL: | |
4 % varargout = mainFnc(inputs, modelFilename, getModelDescription, getModelDocumentation, getVersion, versionTable) | |
5 % | |
6 % A typical call from the built-in model main function will look like: | |
7 % | |
8 % varargout = utils.models.mainFnc(varargin(:), ... | |
9 % mfilename, ... | |
10 % @getModelDescription, ... | |
11 % @getModelDocumentation, ... | |
12 % @getVersion, ... | |
13 % @versionTable); | |
14 % | |
15 % INPUTS: | |
16 % inputs - cell-array of inputs to the built-in model | |
17 % modelFilename - the full filename of the model (typically you use mfilename) | |
18 % getModelDescription - a function handle to the getModelDescription function | |
19 % getModelDocumentation - a function handle to the getModelDocumentation function | |
20 % getVersion - a function handle to the getVersion function | |
21 % versionTable - a function handle to the versionTable function | |
22 % | |
23 % VERSION: $Id: mainFnc.m,v 1.3 2011/04/29 14:25:14 hewitson Exp $ | |
24 % | |
25 % | |
26 function varargout = mainFnc(inputs, modelFilename, getModelDescription, getModelDocumentation, getVersion, versionTable) | |
27 | |
28 % Process inputs | |
29 [info, pl, constructorInfo, fcn] = utils.models.processModelInputs(inputs, ... | |
30 modelFilename, ... | |
31 getModelDescription, ... | |
32 getModelDocumentation, ... | |
33 getVersion, ... | |
34 versionTable); | |
35 | |
36 if ~isempty(info) | |
37 varargout{1} = {info}; | |
38 return; | |
39 end | |
40 | |
41 % Build the object | |
42 hpl = copy(pl, 1); | |
43 out = fcn(pl); | |
44 | |
45 % Set the method version string in the minfo object | |
46 if ~isempty(constructorInfo) && utils.helper.isSubclassOf(class(out), 'ltpda_uoh') | |
47 % If this is a user-call via a constructor, then we add history | |
48 out = addHistoryStep(out, constructorInfo, hpl); | |
49 end | |
50 | |
51 if nargout > 0 | |
52 varargout{1} = {out, pl}; | |
53 else | |
54 error('!!! Invalid number of output') | |
55 end | |
56 | |
57 end |