www.gusucode.com > mbcdesign 工具箱 matlab 源码程序 > mbcdesign/@conbase/upgrade.m
function con = upgrade(con, m) %UPGRADE Upgrade a constraint to have model information % % CON = UPGRADE(CON, M) % % For old forms of the constraint, this method will take all the % appropriate information from the model, M, and update the information in % the constraint, CON. This includes updating variable information and % inverse coding any data stored in coded units. The version number will % also be updated by this method. % % This method should be called from the LOADOBJ method of any object that % holds a constraint. Some objects may need to setup a post-load callback % if they do have an appropriate model at LOADOBJ time. % % See also CONBASE/LOADOBJ. % Copyright 2005-2007 The MathWorks, Inc. and Ford Global Technologies, Inc. % Get the version number if iscell( con.Version ), version = con.Version{1}; else version = con.Version; end % Check if need to upgrade if version == 1.5, % Turn the given model into a friend model m = pMakeFriend( con, m ); % There seems to have been a bug with previous versions on MBC that % menas that a n factor constraint may be associated with a (n-i) % factor model. In this situation, the constraint should have (n-i) % factors, all of which are active. Only CONSTAR, CONRANGE and % CONELLIPSOID constraints should have this problem. nfm = nfactors( m ); if nfm ~= nFactors( con ), if nfm ~= nActiveFactors( con ), warning(message('mbc:conbase:InvalidState8', nFactors( con ), nActiveFactors( con ), nfm)); end con.ActiveFactors = 1:nfm; end % Upgrade input factor information con.InputFactors = coninputfactor( m ); % Update version number version = 2.0; end % Set the version number if iscell( con.Version ), con.Version{1} = version; else con.Version = version; end