www.gusucode.com > mbcmodels 工具箱 matlab 源码程序 > mbcmodels/@xregoptmgr/private/pGetPropertyIndex.m

    function ind = pGetPropertyIndex(OM, Property,AllProperties)
%PGETPROPERTYINDEX Find the indices of a property
%
%  IND = PGETPROPERTYINDEX(OM, PROP) returns the indices that match the
%  property name PROP.  Partial matches are allowed, so IND may contain
%  none, one or many indices.

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


if ~isempty(OM.foptions)
    opts = {OM.foptions.Param};
else
    opts = {};
end

% First check case-sensitive string matches
ind = i_findstring(Property, opts);
nFound = length(ind);

% Now check case-insensitive matches
if nFound~=1
    ind = i_findstring(lower(Property), lower(opts));
end

if nargin>2 && ~AllProperties
    % only show gui settable properties
    PublicProperties = [OM.foptions.GuiSetable];
    PublicProperties = logical(PublicProperties(ind));
    ind = ind(PublicProperties);
end
    


function ind = i_findstring(str, opts)
ind = find(strncmp(str, opts, length(str)));
if length(ind)>1
    % Check for an exact match vs partial matches.
    isExact = strcmp(str, opts(ind));
    if any(isExact)
        ind = ind(isExact);
    end
end