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

    function obj = loadobj(obj)
%LOADOBJ Method to update old versions of optim node objects
%
%  OBJ = LOADOBJ(OBJ) is called during loading to upgrade old version of an
%  object.

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


if isstruct(obj) && ~isfield(obj, 'Version')
    % Version 1 object structure - need to add storage of outputs
    obj.OutputData = mbcpointer(1,0);
    obj.Version = 2;
    

    % Schedule a post load action to get the new output object from the
    % cgoptim.  Date number is 30-August-2005.
    h = mbcloadrecorder('current');
    h.add({@i_changeobject, address(obj.cgcontainer)},732554);
end

if isstruct(obj)
    obj = cgoptimnode(obj);
end



function i_changeobject(Proj, evt, pNode)
% Get output object from optim and set it as the output data for this node,
% and also place it in the output node.
pOptim = pNode.getdata;
pOutNode = pNode.children;
if ~isempty(pOutNode)
    pOutNode = pOutNode(1);
    OutputObj = pOptim.upgradeV10ToV11('getoutput');
    OutputObj = setname(OutputObj, pOutNode.name);
    pOut = xregpointer(OutputObj);
    pOutNode.setdata(pOut);
    pNode.setOutput(pOut, 1);
end