www.gusucode.com > bigdata 工具箱 matlab源码程序 > bigdata/@tall/count.m

    function c = count(s,varargin)
%COUNT Returns the number of occurrences of a pattern in a string.
%   C = COUNT(S,PATTERN)
%   C = COUNT(S,PATTERN,'IgnoreCase',IGNORE)
%
%   See also TALL/STRING.

%   Copyright 2016 The MathWorks, Inc.

narginchk(2,4);

% First input must be tall. Rest must not be.
checkNotTall(upper(mfilename), 1, varargin{:});

% This method is string-specific
s = tall.validateType(s, mfilename, {'string'}, 1);

% Result is one number per string
c = elementfun(@(x) count(x,varargin{:}), s);
c.Adaptor = copySizeInformation(matlab.bigdata.internal.adaptors.getAdaptorForType('double'), ...
                                s.Adaptor);
end