www.gusucode.com > mbcexpr 工具箱 matlab 源码程序 > mbcexpr/@cgnormfunction/getvariables.m

    function [variables, problem, othervariables] = getvariables(NF,expr)
%GETVARIABLES Group common input variables
%
%  [COMMON, MSG, EXTRA] = GETVARIABLES(NF, EXPR) returns the set of inports
%  to NF that are also inports to EXPR in COMMON and all other inports to
%  EXPR in EXTRA.  If the input of the table does not have a single
%  variable in common with EXPR, MSG will be a non-empty string containing
%  an appropriate message.

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


problem = '';

[variables,unused] = cgvardiff(NF.Xexpr,expr);

lx = length(variables);
if lx == 0 
    problem = 'One of the table variables does not appear in the model.';
elseif lx > 1
    problem = 'This table has more than one variable in common with the model.';
end

if nargout > 2
    % find the other variables
    [unused, othervariables] = cgvardiff(expr,variables);
end