www.gusucode.com > mbc 工具箱 matlab 源码程序 > mbc/@xregpointer/findptrs.m

    function pos= findptrs(p,q)
%FINDPTRS find location of pointers in another list
%
%   IND = FINDPTRS(P,Q) returns the index to pointers P in list Q

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



pos= zeros(size(p));
if ~isempty(p) && ~isempty(q)
    p= p.ptr;
    q= q.ptr;
    n= numel(q);
    for i = 1:numel(p)
        % this code is jittable
        j=1;
        while j<=n && p(i)~=q(j)
            % find first instance of p(i) in q
            j=j+1;
        end
        if j<=n
            % p(i) is found at j
            pos(i) = j;
        end
    end
end