www.gusucode.com > mbcdesign 工具箱 matlab 源码程序 > mbcdesign/@constar/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. if con.Version == 4.5, m = pMakeFriend( con, m ); % Upgrade parent con.conbase = upgrade( con.conbase, m ); % Need to inverse code the center oldCenter = con.Center; con.Center = invcode( m, con.Center, getActiveIndices( con ) ); % In the old version the model will have no effective coding and the % coding will have been done by some "friend" model. Thus we now need % to set the coding of the model. % % Ideally, we would use to the standard method to set the model coding % as the parent CONBASE has been upgraded, i.e, % >> con = pSetModelCoding( con ); % However, the order of "shift by center" and "code data" has changed % from the old to the new. To get around this, we need to set the % target coding so that model operates in coded a space that is shifted % by the (old) center. cif = getActiveFactors( con ); mn = cif.Min - con.Center; mx = cif.Max - con.Center; tgt = [-1 - oldCenter; 1 - oldCenter].'; con.Model = setcode( con.Model, [mn(:), mx(:)], '', tgt ); % Update version number con.Version = 6.0; end %------------------------------------------------------------------------------| % EOF %------------------------------------------------------------------------------|