www.gusucode.com > mbcexpr 工具箱 matlab 源码程序 > mbcexpr/@cgslblock/private/pfind.m

    function [FOUND, ind] = pfind( obj, b )
%PFIND Finds the cgslblock entry for the given block
%
%  [FOUND, index] = pfind( cgslblock, blockhandle )

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



FOUND = false;
ind = 1:length( obj );

blocktype = get_param(b,'blocktype');
if ~any(  strncmp( blocktype,{ 'SubSystem', 'S-Function' },length(blocktype) ) )
    % find blocktype
    ind = find( strcmp( blocktype,{ obj.blocktype } ) );
    if length(ind)==1
        FOUND = true;
    end
end

if ~FOUND
    masktype = get_param(b, 'MaskType');
    % find on masktype
    ind = intersect(find( strcmp( masktype,{ obj.masktype } ) ), ind);
    if length(ind)==1
        FOUND = true;
    end
end

if ~FOUND
    tagtype =  get_param(b, 'Tag');
    % find on tagtype
    ind = intersect(find( strcmp( tagtype,{ obj.tagtype } ) ), ind);
    if length(ind)==1
        FOUND = true;
    end
end