www.gusucode.com > mbc 工具箱 matlab 源码程序 > mbc/@mbcmodel/@localresponse/CreateResponseFeature.m
function RF = CreateResponseFeature(LocalResponse,RFType,EvaluationPoint) %CREATERESPONSEFEATURE create new response feature % % RF = CreateResponseFeature(LocalResponse,RFType) % RF = CreateResponseFeature(LocalResponse,RFType,EvaluationPoint) % RFType is a description string belonging to the set of % alternative response features for the current local model. % EvaluationPoint is a row vector with an element for each model input % and is used for response features that require an input value to % evaluate the response feature (e.g. function evaluation, % derivatives). It is an error to specify an evaluation point for a % response feature type that does not require an evaluation point. % % See also mbcmodel.responsefeatures.Add, mbcmodel.responsefeatures.getAlternativeTypes % Copyright 2007-2011 The MathWorks, Inc. mdev = LocalResponse.Object; m = model(mdev); OldModel = m; F = features(m); ind = find(strcmp(RFType,{F.Display})); if nargin<3 EvaluationPoint = NaN(1,nfactors(m)); elseif ~isnumeric(EvaluationPoint) || ~all(size(EvaluationPoint)==[1 nfactors(m)]) error('mbc:mbcmodel:localresponse:InvalidArgument',... 'Evaluation points must be a row vector with %d elements',nfactors(m)) end if ~isempty(ind) m = AddFeat(m,EvaluationPoint,ind); LocalResponse.Object = m; else error('mbc:mbcmodel:localresponse:InvalidArgument',... 'Invalid response features for %s',getType(m)); end vals = get(m,'EvaluationPoints'); if nargin>2 && isempty(vals{end}) % must not specify evaluation points error(message('mbc:mbcmodel:responsefeatures:InvalidArgument1', RFType)) elseif nargin<2 && ~isempty(vals{end}) % must specify evaluation points error(message('mbc:mbcmodel:responsefeatures:InvalidArgument2', RFType)) end % add new response feature mdev = model(mdev,m); prf = makechildren(mdev); if prf~=0 % new rf added RF = LocalResponse.ResponseFeatures(end); else Name = RespFeatName(m); warning('mbc:mbcmodel:localresponse:InvalidState',... 'The response feature %s already exists. An alternative global model can be constructed by creating submodels.',Name{end}) ; RF = mbcutils.handleArray(0); % restore old model model(mdev,OldModel); end