www.gusucode.com > mbctools 工具箱 matlab 源码程序 > mbctools/@xregtools/@DiagnosticStatsTable/pUpdateTable.m

    function pUpdateTable(obj, mdev, type, SNo, L, X, Y)
%PUPDATETABLE Private function
%
%  PUPDATETABLE(OBJ, MD, TYPE, SWEEPNUMBER, LOCALMODEL, X, Y)

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


if isempty( mdev )
    obj.Peer.clearTable();
    return;
elseif ~isa( mdev, 'mdev_local' )
    error(message('mbc:DiagnosticStatsTable:InvalidArguments'));
end

if nargin<5
    [X, Y] = getdata( mdev );
    X = X(:,:,SNo);
    Y = Y(:,:,SNo);
    [L, OK] = LocalModel( mdev, SNo );
end

[OK, Stats, InSig, labs, head] = localstats( mdev, SNo, obj.pConvertTypeToIndex( type ), L, X, Y );

% deTeX the labels (empty if this test not fitted)
if ~isempty(labs),
    labs = strrep(labs,'\','');
    % work out width for table
    nc= max(cellfun(@length,labs));
    len= min(max(nc*6,100),200);
    obj.Peer.setRowHeaderWidth( len )
end;
if ~isempty(head),
    head = strrep(head,'\','');
end;

if OK
    switch type
        case {'LocalCorrelations', 'GlobalCovariance'}
            % need to make some cells invisible!
            InvisibleIndex = (triu(ones(size(Stats)),1)~=0);
        otherwise
            InvisibleIndex = false( size( Stats ) );
    end
    % any NaN cells are invisible as well
    InvisibleIndex = InvisibleIndex | isnan( Stats );
    
    %store up the set calls so we only have to redraw the table once.
    obj.Peer.setStoreSwingCalls( true );
    obj.Peer.setRowData( labs );
    if isempty( head )
        obj.Peer.setDisplayColumnHeaders( false );
    else
        obj.Peer.setDisplayColumnHeaders( true );
        obj.Peer.setColumnData( head );
    end
    obj.Peer.setTableData( Stats );
    iHighLightInSignificantCells( obj, Stats, InSig );
    obj.Peer.setCellVisible( ~InvisibleIndex );
    % flush all the set calls we have been storing.
    obj.Peer.setStoreSwingCalls( false );
else
    obj.Peer.clearTable();
end

function iHighLightInSignificantCells( obj, Stats, InSig )

% we highlight (in some way) the rows where InSig is true.
cellColorsR = zeros( size( Stats ) );
cellColorsG = zeros( size( Stats ) );
cellColorsB = zeros( size( Stats ) );
% set the InSig cells to some new color...dark red in this case
cellColorsR( InSig, : ) =  0.8;
cellColorsG( InSig, : ) =  0;
cellColorsB( InSig, : ) =  0;
obj.Peer.setForegroundRGB( cellColorsR, cellColorsG, cellColorsB );