www.gusucode.com > mbcmodels 工具箱 matlab 源码程序 > mbcmodels/@xregoptmgr/checkinput.m
function [OK,Value] = checkinput(OM,pind,Value) %CHECKINPUT % % [OK = checkinput(OM,pind,Value) % Copyright 2006 The MathWorks, Inc. and Ford Global Technologies, Inc. Type= OM.foptions(pind).CheckInput; if ~isempty(OM.foptions(pind).Name) % use name if it is defined Property = OM.foptions(pind).Name; else % use internal property name Property = OM.foptions(pind).Param; end % general checking - an error is thrown if the new value is invalid if iscell(Type) Options = Type{2}; Type = Type{1}; else Options = []; end OK = mbcCheckInput(Value,Type,Options,Property); OldValue = OM.foptions(pind).Value; % optim manager specific checks if ischar(Type) && strcmpi(Type,'evalstr') % eval string could be numeric or include a try/catch expression if isnumeric(Value) Value = num2str(Value); end if ischar(Value) && iscell(OldValue) && strcmpi(Type,'evalstr') % {Expr,CatchExpr} OldValue{1}= Value; Value= OldValue; end elseif isa(Value,'xregoptmgr') % need to check whether to algorithm is a valid alternative if ~IsAlternative(Value,OldValue); error(message('mbc:xregoptmgr:InvalidValue', Property)) end % copy alternatives alts = OldValue.Alternatives; if ~isempty(alts) Value.Alternatives = OldValue.Alternatives; end % switch IsMaster off by default Value.IsMaster= 0; end