www.gusucode.com > mbcmodels 工具箱 matlab 源码程序 > mbcmodels/@term_selector/checkterms.m

    function checkterms(t, row)
%CHECKTERMS   Callback function
%   Callback function for the term_selector object.  This
%   callback will not work from the command line.
%

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


% This is the callback activated when a a section of terms
% is toggled in/out of the model

ud=get(t.xregtable,'UserData');
m=ud.model;

CHECK_COL = 1;

CheckInd = (ud.chboxrows==row);

switch ud.chboxstate(CheckInd)
    case 0
        % was off - got to on
        tgcol=[0 0.85 0];
        stat=3;
        str='in';
        val=0;
        ud.chboxstate(CheckInd) = 2;
        
    case 1
        % checkbox was partial (grayed) - go to off
        t.xregtable(row,CHECK_COL).value=0;
        t.xregtable(row,CHECK_COL).enable='on';
        t.xregtable(row,CHECK_COL).buttondownfcn = '';
        
        tgcol=[0.85 0 0];
        stat=2;
        str='out';
        val=1;
        ud.chboxstate(CheckInd) = 0;
    case 2
        % was on - go to off
        tgcol=[0.85 0 0];
        stat=2;
        str='out';
        val=1;
        ud.chboxstate(CheckInd) = 0;
end

% get section
sect=find(row==ud.chboxrows);

% update model
m=setstatus(m,ud.termsind(ud.termsbrkstart(sect):(ud.termsbrkstart(sect)+ud.termsbreak(sect)-1)),stat);
m=SetTerm(m,ud.termsind(ud.termsbrkstart(sect):(ud.termsbrkstart(sect)+ud.termsbreak(sect)-1)),(stat>2));

% update table
t.xregtable(ud.btnrows(ud.termsbrkstart(sect):(ud.termsbrkstart(sect)+ud.termsbreak(sect)-1)),4).backgroundcolor=tgcol;
t.xregtable(ud.btnrows(ud.termsbrkstart(sect):(ud.termsbrkstart(sect)+ud.termsbreak(sect)-1)),4).string=str;
t.xregtable(ud.btnrows(ud.termsbrkstart(sect):(ud.termsbrkstart(sect)+ud.termsbreak(sect)-1)),4).value=val;

ud.model=m;
set(t.xregtable,'UserData',ud);

if ~isempty(ud.updatefunction)
   % parse for %model
   if ~iscell(ud.updateparams)
      ud.updateparams={ud.updateparams};
   end
   
   for m=1:length(ud.updateparams)
      if ischar(ud.updateparams{m})
         if strcmp(ud.updateparams{m},'%MODEL')
            ud.updateparams{m}=ud.model;
         end
      end
   end
   feval(ud.updatefunction,ud.updateparams{:})
end