www.gusucode.com > mbcdesign 工具箱 matlab 源码程序 > mbcdesign/@conellipsoid/loadobj.m

    function con = loadobj(con)
%LOADOBJ Load filter for ellipsoid constraint objects
%
%  CON = LOADOBJ(CON)
%
%  For old forms of constraints, the LOADOBJ method updates the object
%  structure and partially increments the version number. Where required,
%  nominal values will be used for the variable information, etc. Use the
%  UPGRADE method to update this information.
%
%  See also LOADOBJ, CONBASE/LOADOBJ, CONELLIPSOID/UPGRADE.

%  Copyright 2000-2008 The MathWorks, Inc. and Ford Global Technologies, Inc.

if con.version == 3.5,
    warning(message('mbc:contable1:MissedUpgrade'));
end
% Upgrade from version 1 to version 2 structure.
if con.version <= 1
    con.scalefactor = 1;
    con.version = 2;
end
% Upgrade from version 2 to version 3 structure.
if con.version <= 2,
    % This was previously handled by the constructor
    %
    %              xc:
    %               W:
    %         version: 2
    %     scalefactor:
    %
    % Create parent abstract class
    con.conbase = conbase( coninputfactor( length( con.xc ) ) );
    % However, the parent is really only at version 1.5 because it will
    % need an UPGRADE.
    con.conbase = pSetVersionNumber( con.conbase, 1.5 );
    % Increment the version number:
    con.version = 3;
end
% Upgrade from version 3 to version 4 structure.
if con.version <= 3,
    %
    %              xc: [0 0 0 0]
    %               W: [4x4 double]
    %         version: 3
    %     scalefactor: 1
    %         conbase: [1x1 conbase]
    %
    % No structure upgrade required. However, we will need an UPGRADE to
    % move "xc" and "W" into natural units.
    % Partial increment of the version number:
    con.version = 3.5;
end

if con.version <= 4
    % add an offset to account for rounding error
    con.Offset = 0;
    if con.version ~= 3.5
        % we don't need to go through upgrade
        con.version = 5;
    end
end
if isstruct( con ),
    % Convert the structure to an object.
    con = conellipsoid( con );
end

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