www.gusucode.com > mbcview 工具箱matlab源码程序 > mbcview/@cgtradeoffgui/@mmSiteGraphView/pUpdateAxesLimits.m

    function pUpdateAxesLimits(obj)
%PUPDATEAXESLIMITS Set the axes limits correctly
%
%  PUPDATEAXESLIMITS(OBJ) sets the axes limits to be the union of the model
%  limits and the range of the breakpoints for each switch factor.

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


if ~isempty(obj.MessageService) ...
        && length(obj.MessageService.SwitchInputs)==2
    mdl = obj.MessageService.SampleTakenModel;
    bps = obj.MessageService.Breakpoints;
    
    % Get limits from model
    [L, U] = range(mdl);
    sfIndex = getSwitchFactors(mdl);
    lims = [L(sfIndex)', U(sfIndex)'];

    % Expand limits to include breakpoints
    i_expandlimits(1);
    i_expandlimits(2);
    
    axisorder = obj.MessageService.AxisOrder;
    set(obj.hAxes, 'XLim', lims(axisorder(2), :), ...
        'YLim', lims(axisorder(1),:));
    inputs = obj.MessageService.SwitchInputs;
    mbcxlabel(obj.hAxes, inputs{axisorder(2)});
    mbcylabel(obj.hAxes, inputs{axisorder(1)});
else
    set(obj.hAxes, 'XLim', [0 1], 'YLim', [0 1]);
    mbcxlabel(obj.hAxes, '');
    mbcylabel(obj.hAxes, '');
end

    % Function that checks whether limits need expanding to include breakpoints
    function i_expandlimits(factidx)
        if ~isempty(bps{factidx})
            bplim = [min(bps{factidx}), max(bps{factidx})];
            if lims(factidx, 1) > bplim(1)
                lims(factidx, 1) = bplim(1);
            end
            if lims(factidx, 2) < bplim(2)
                lims(factidx, 2) = bplim(2);
            end
        end
    end
end