www.gusucode.com > mbcdesign 工具箱 matlab 源码程序 > mbcdesign/@contable2/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/UPGRADE, CONTABLE2/LOADOBJ.

%  Copyright 2005-2007 The MathWorks, Inc. and Ford Global Technologies, Inc.



if con.version == 1.5,
    m = pMakeFriend( con, m );
    % Upgrade parent
    con.conbase = upgrade( con.conbase, m );
    % Adjust the "breakcols", "breakrows" and "table" to take account of
    % the change in coding 
    %  -- The INVCODE method of the model can map these values from coded
    %     units to natural units. 
    ai = getActiveIndices( con );
    con.breakcols(:) = invcode( m, con.breakcols(:), ai(1) );
    con.breakrows(:) = invcode( m, con.breakrows(:), ai(2) );
    con.table(:)     = invcode( m, con.table(:),     ai(3) );
    % Update version number
    con.version = 2.0;
end

%------------------------------------------------------------------------------|
% EOF
%------------------------------------------------------------------------------|