www.gusucode.com > mbcdata 工具箱 matlab 源码程序 > mbcdata/@cgoptimtablefiller/private/pCheckTables.m

    function [ok, msg] = pCheckTables(pTabsExist, pTabsNew)
%PCHECKTABLES Check validity of tables
%
%   [OK, MSG] = PCHECKTABLES(pTABSEXIST, pTABSNEW) checks to see if the new
%   tables can be added to the table filler.

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


ok = true;
msg='';

if ~all(isa(pTabsNew, 'xregpointer')) || ~all(isvalid(pTabsNew)) 
    ok = false;
    msg = 'PTABNEW must be a vector of tables';
end

if ok
    try
        fillstat = pveceval(pTabsNew, @isfill);
        fillstat = [fillstat{:}];
        ok = all(fillstat);
    catch
        ok = false;
    end

    if ~ok
        msg = 'PTABNEW must be a vector of tables that can be filled';
    end
end


% Ensure that the new tables are unique and are not already in the table
% filler
if ok
    pAllTabs = [pTabsExist, pTabsNew];
    ok = isequal(length(unique(pAllTabs)), length(pAllTabs));
    if ~ok
        msg = 'OBJ.TABLES must be a unique list';
    end
end