www.gusucode.com > mbcdesign 工具箱 matlab 源码程序 > mbcdesign/@coninputfactor/find.m

    function loc = find(cifA, cifB)
%FIND Find location of one vector of input factors within another.
%
%  LOC = FIND(CIFA, CIFB) finds the location of CIFA in CIFB and returns a
%  vector of indices.  Input factors in CIFA that are not in CIFB are
%  assigned an index of 0.  Input factors in CIFA that match more than one
%  input factor in CIFB return the first matching index.
%
%  See also CONINPUTFACTOR.

%  Copyright 2006 The MathWorks, Inc.


loc = zeros(size(cifA));
if isa( cifA, 'coninputfactor' ) && isa( cifB, 'coninputfactor' )
    for n = 1:length(cifA)
        idx = find(cifA.Max(n)==cifB.Max ...
            & cifA.Min(n)==cifB.Min ...
            & strcmp(cifA.Name{n}, cifB.Name) ...
            & strcmp(cifA.Symbol{n}, cifB.Symbol) ...
            & strcmp(cifA.Unit{n}, cifB.Unit));
        if ~isempty(idx)
            loc(n) = idx(1);
        end
    end
end