view m-toolbox/test/template_test_models/ao_model_a.m @ 52:daf4eab1a51e
database-connection-manager tip
Fix. Default password should be [] not an empty string
author
Daniele Nicolodi <nicolodi@science.unitn.it>
date
Wed, 07 Dec 2011 17:29:47 +0100 (2011-12-07)
parents
f0afece42f48
children
line source
+ − %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ − %
+ − % DESCRIPTION: Builtin model for A
+ − %
+ − % This model adds together model 'b' and model 'c'.
+ − %
+ − %
+ − % CALL:
+ − % p = ao(plist('built-in','a'))
+ − %
+ − % INPUTS:
+ − %
+ − %
+ − % OUTPUTS:
+ − % - p: an AO object representing a
+ − %
+ − %
+ − % INFO:
+ − % <a href="matlab:web(modelOverview(ao_model_a('info')), '-helpbrowser')">Model Information</a>
+ − %
+ − %
+ − % REFERENCES:
+ − %
+ − %
+ − % VERSION: $Id: ao_model_a.m,v 1.4 2010/09/16 09:10:17 hewitson Exp $
+ − %
+ − % HISTORY:
+ − %
+ − %
+ − %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ −
+ −
+ − function varargout = ao_model_a(varargin)
+ −
+ − % Process inputs
+ − [info, pl, constructorInfo, fcn] = utils.models.processModelInputs(varargin(:), ...
+ − mfilename, ...
+ − @getModelDescription, ...
+ − @getModelDocumentation, ...
+ − @getVersion, ...
+ − @versionTable);
+ − if ~isempty(info)
+ − varargout{1} = info;
+ − return;
+ − end
+ −
+ − % Build the object
+ − out = fcn();
+ −
+ − % Set the method version string in the minfo object
+ − if ~isempty(constructorInfo)
+ − % If this is a user-call via a constructor, then we add history
+ − out = addHistoryStep(out, constructorInfo, pl);
+ − end
+ −
+ − if nargout > 0
+ − varargout{1} = out;
+ − varargout{2} = pl;
+ − else
+ − error('!!! Invalid number of output')
+ − end
+ − end
+ −
+ −
+ − %--------------------------------------------------------------------------
+ − % AUTHORS EDIT THIS PART
+ − %--------------------------------------------------------------------------
+ −
+ − function desc = getModelDescription
+ − desc = 'My nice model which adds together two other models, $b+c$.';
+ − end
+ −
+ − function doc = getModelDocumentation
+ − doc = sprintf([...
+ − 'This model does the amazing mathematical plus operation.\n'...
+ − '<br><br>\n'...
+ − '$b+c$\n'...
+ − ]);
+ − end
+ −
+ − % default version is always the first one
+ − function vt = versionTable()
+ −
+ − vt = {...
+ − 'Better Version', @version2, ...
+ − 'Version One', @version1, ...
+ − };
+ −
+ − end
+ −
+ − % This version uses:
+ − % model b, version 'alpha'
+ − % model c, version 'initial'
+ − %
+ − function varargout = version1(varargin)
+ −
+ − if nargin == 1 && ischar(varargin{1})
+ − switch varargin{1}
+ − case 'plist'
+ −
+ − % The plist for this version of this model
+ − pl = plist();
+ −
+ − % parameter a
+ − p = param({'a', 'Parameter a of the model'}, paramValue.DOUBLE_VALUE(1));
+ − pl.append(p);
+ −
+ − % set output
+ − varargout{1} = pl;
+ −
+ − case 'description'
+ − varargout{1} = 'Using model b version ''alpha'' and model c version ''initial''.';
+ − case 'info'
+ − varargout{1} = [ao_model_b('info', 'alpha') ao_model_c('info', 'initial')];
+ − otherwise
+ − error('unknown inputs');
+ − end
+ − return;
+ − end
+ −
+ − % build model
+ −
+ − b = ao_model_b(plist('version', 'alpha'));
+ − c = ao_model_c(plist('version', 'initial'));
+ −
+ −
+ − varargout{1} = b+c;
+ −
+ − end
+ −
+ −
+ − % This version uses:
+ − % model b, version 'alpha'
+ − % model c, version 'second'
+ − %
+ − function varargout = version2(varargin)
+ −
+ − if nargin == 1 && ischar(varargin{1})
+ − switch varargin{1}
+ − case 'plist'
+ −
+ − % The plist for this version of this model
+ − pl = plist();
+ −
+ − % parameter a
+ − p = param({'a', 'Parameter a of the model'}, paramValue.DOUBLE_VALUE(10));
+ − pl.append(p);
+ −
+ − % Expose some parameters of the submodel b
+ − plb = ao_model_b('plist', 'alpha');
+ − plb = plb.subset('b');
+ − pl.combine(plb);
+ −
+ − % set output
+ − varargout{1} = pl;
+ −
+ − case 'description'
+ − varargout{1} = 'Using model b version ''alpha'' and model c version ''second''.';
+ − case 'info'
+ − varargout{1} = [ao_model_b('info', 'alpha') ao_model_c('info', 'second')];
+ − otherwise
+ − error('unknown inputs');
+ − end
+ − return;
+ − end
+ −
+ − % build model
+ −
+ − b = ao_model_b(plist('version', 'alpha'));
+ − c = ao_model_c(plist('version', 'second'));
+ −
+ −
+ − varargout{1} = b+c;
+ − end
+ −
+ − %--------------------------------------------------------------------------
+ − % AUTHORS SHOULD NOT NEED TO EDIT BELOW HERE
+ − %--------------------------------------------------------------------------
+ −
+ −
+ − %--------------------------------------------------------------------------
+ − % Get Version
+ − %--------------------------------------------------------------------------
+ − function v = getVersion
+ −
+ − v = '$Id: ao_model_a.m,v 1.4 2010/09/16 09:10:17 hewitson Exp $';
+ −
+ − end