www.gusucode.com > mbc 工具箱 matlab 源码程序 > mbc/@mbcmodel/@responsefeatures/Add.m

    function RF = Add(RF,RFtype,EvaluationPoint)
%ADD add a new response feature to response feature set
%
%  RF = Add(RF,RFtype)
%  RF = Add(RF,RFtype,EvaluationPoint)
%     RFtype is a description string belonging to the set of
%           alternative response features getAlternativeTypes
%     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.Remove, mbcmodel.responsefeatures.Select,
% mbcmodel.responsefeatures.getAlternativeTypes,
% mbcmodel.localresponse.CreateResponseFeature

% Copyright 2007-2008 The MathWorks, Inc.


L = RF.Object;
F = features(L);

ind = find(strcmp(RFtype,{F.Display}));

if nargin<3
    EvaluationPoint = NaN(1,nfactors(L));
end

if ~isnumeric(EvaluationPoint) || ~all(size(EvaluationPoint)==[1 nfactors(L)])
    error('mbc:mbcmodel:responsefeatures:InvalidArgument',...
        'Evaluation points must be a row vector with %d elements',nfactors(L))
end

if ~isempty(ind)
    L = AddFeat(L,EvaluationPoint,ind);
    
    RF.Object = L;
    vals = get(L,'EvaluationPoints');
    if nargin>2 && isempty(vals{end})
        % must not specify evaluation points
        error(message('mbc:mbcmodel:responsefeatures:InvalidArgument4', RFtype))
    elseif nargin<3 && ~isempty(vals{end})
        % must specify evaluation points
        error(message('mbc:mbcmodel:responsefeatures:InvalidArgument5', RFtype))
    end
else
    error(message('mbc:mbcmodel:responsefeatures:InvalidArgument6', getType( L )));
end