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

    function out = ismissing(in, varargin)
%ISMISSING  Find elements in a table that contain missing values.
%
%   I = ISMISSING(T)
%   I = ISMISSING(T,INDICATORS)
%
%   Returns a tall.
%
%   See also: ISMISSING, TALL/STANDARDIZEMISSING.

% Copyright 2015-2016 The MathWorks, Inc.

narginchk(1, maxArgsForInput(in));
in = tall.validateType(in, mfilename, {'string','table'}, 1);
if nargin>1
    % Check that the indicators are sane at parse time. Indicators must be
    % a double array, a cellstr or a cell containing mixed strings and
    % doubles.
    indicators = varargin{1};
    if ~isValidIndicator(indicators)
        error(message('MATLAB:ismissing:IndicatorsInvalidType', class(indicators)));
    end
    
end

% We get back a tall logical with the same size as the table
out = elementfun(@(t) ismissing(t, varargin{:}), in);

out.Adaptor = matlab.bigdata.internal.adaptors.getAdaptorForType('logical');
if ~isnan(in.Adaptor.NDims)
    out.Adaptor = setKnownSize(out.Adaptor, in.Adaptor.Size);
end
end


function n = maxArgsForInput(in)
% Determine how many inputs are allowed for this input argument type
adaptor = matlab.bigdata.internal.adaptors.getAdaptor(in);
% Table allows a second input, string just the one.
if strcmp(adaptor.Class, 'table')
    n = 2;
else
    n = 1;
end

end


function tf = isValidIndicator(arg)
% Check whether the input argument is a valid missing value indicator
tf = isStringOrDouble(arg) ...
    || iscellstr(arg) ...
    || (iscell(arg) && all(cellfun(@isStringOrDouble, arg)));
end


function tf = isStringOrDouble(in)
tf = ischar(in) || isstring(in) || isa(in,'double');
end